My intention was to focus on frontend dev., now I stuck with API requests (no data -> no frontend)
I was about to build up a small app with the data of the yahoo finance API. Here I have a problem with CORS.
Even a CORS proxy (see below) does not work.
Ok, taking a step back, I chose https://dummyapi.io/ in order to practice the whole thing.
When I don’t have problems with CORS here, I cannot access the JSON data,
Here is the basic code that I used for dummyapi:
Code: Select all
const url =
"https://cors-anywhere.herokuapp.com/https://n161.tech/api/dummyapi/user?limit=5&page1";
fetch(url)
.then((res) => {
console.log(res);
return res.json();
})
.then((data) => {
console.log(data);
});
error: index.html:1 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
Does anybody have a hint how to approach this whole thing? (Honestly speaking I would be happy to have a black box where I can send my AJAX requests, fetch my data and focus on the fronent dev. But life is not so easy!)