Trying to fetch Openwhyd Data Export API endpoint https://openwhyd.org/hot?format=json using React with JS fetch(), but it doesn't run on localhost:3000, it gives the following error:
Access to fetch at 'https://openwhyd.org/hot?format=json' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
If there is a way to fix from within the React App?
Part of my code that fetches the API:
// fetch the data from the API endpoint
componentDidMount() {
fetch('https://openwhyd.org/hot?format=json'})
.then(res => res.json())
.then(
(result) => {
console.log(result);
}
)
}
I tried using mode: "no-cors"
, but then the respose from the API fetch() is not usable for data output.
OS: maciOS Mojave Version 10.14.5 Browser: Chrome Version 84.0.4147.89 (Official Build) (64-bit)