Hello here is my problem:
I have to get some data to an external api (http://example.com/api/ who doesn't support OPTIONS
) from my react app running in local with webpack-dev-server.
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState === 4) {
try {
if (xhr.status === 200) {
let response = JSON.parse(xhr.responseText);
success(response);
} else {
error(xhr.responseText);
}
}
catch(err) {
console.error(err);
error(err);
}
}
};
The status is always at 0 but 200 on the network.
I'm completely lost, how can makes it work ?