Hello,
My aim was to concetrate on building up a front-end, now I stuck with API requests (no data -> no frontend)
My first approach was to load data via AJAX from the yahoo finance API. Here I have a problem with CORS.
Ok, take 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 (for whatever reason),
Here is the code that I used for dummyapi:
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
Ok, I don’t get JSON back here, looks more like HTML…
Is there a way to approach the whole topic!?? Thanks.