Replies: 4 comments 3 replies
-
I finally figured out how to retrieve the JSON data. I used the generated API key.
I did have a question. Is this a safe way to retrieve the data in plain JS? This is what it logged: |
Beta Was this translation helpful? Give feedback.
-
It is odd to me that you have auth.useAPIKey on the posts collection. This effectively means the parts are authorized like you think of a user and your collection is given extra fields like salt and hash the way you have it now. I like that your posts has I would remove auth on posts and try to fetch again without the header with the API key. Unless I really don't understand your intention there. The docs have a rest example using fetch https://payloadcms.com/docs/queries/overview#rest-queries Maybe that example could be improved. I think in your original example you were missing an |
Beta Was this translation helpful? Give feedback.
-
Hey Lub- |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Hi,
When I found Payload CMS on the internet, I was really excited to try it out. I have been able to figure out how to customize Payload, but the only thing I have not been able to figure out is how to access the API. When I go to the API link (localhost:3000/api/posts/643fd24685ae1fb43b01f2ba), I can see the JSON data. When I try to fetch it in JS, I get an error. I have attached a screenshot of the error.
Here is the code I used to fetch the API:
Here is the Posts code for the collection:
I have tried searching through the community support on Payload, and other places, and I still cannot figure out how to access it. I really want to use this really cool CMS, but it's almost useless if I can't access the data. I want to build websites with ReactJS and Astro, and use Payload as my CMS, but I can't figure out how to access the data.
I would greatly appreciate the help.
Beta Was this translation helpful? Give feedback.
All reactions