Reputation: 2896
According to this SO post I should be able to run a fetch request from Chrome devtools console. In fact, if I click the button in the post answer, it works.
However, if I try to execute the very same code in the console, it doesn't work.
fetch('https://jsonplaceholder.typicode.com/posts/1')
.then(res => res.json())
.then(console.log)
What's missing?
Upvotes: 4
Views: 2660
Reputation: 2896
Don't know why, however it depends on the current domain the browser is:
Home page:
After browsing a page (whatever page):
My guess would be that in the first case there is not an established source domain, but a better error description would help.
Upvotes: 6