This is driving crazy, I have a API json rest that I can access perfectly from thefirefox extension RESTED and directly from the browser I can see the data but when I tried my code it said "code: "rest_cannot_access", message: "Only authenticated users can access the REST API.". So I don't understand why.
It's a wordpress rest api plugin, and I tried to get the data from fetch javascript.this is the url http://laprensainsolita.com/wp-json/wp/v2/posts
this is my code to test.
.then(response => {
return response.json()
})
.then(data => {
console.log(data)
})
.catch(err => {
console.log(data)
})
I think you should take a look here https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/
For sure you are logged in by a cookie. Try to open a "private browser window" and you will get the same error.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.