When I click the button, I am executing this function. Despite adding a header in my API, an error is still being displayed.
Here is the code snippet for the function:
let getData = () => {
console.log("getData function started");
const options = {
method: "GET",
headers: new Headers({ 'content-type': 'application/json' }),
mode: 'no-cors'
};
fetch("http://167.71.226.242/", options).then((response) => {
console.log("Inside 1st then");
return response.json();
}).then((data) => {
console.log("Inside 2nd then");
console.log(data);
});
}