I am fetching a url using fetch in react redux application which looks like:
fetch(url, {
mode: 'no-cors',
method: method || null,
headers: headers || null,
body: form || null,
}).then(function(response) {
console.log(response.status)
console.log("response");
console.log(response);
}).then(function(data){
console.log(data)
console.log(data)
})
Strange this is happening. When I call the url it is called and the response is 200. When I see in the console for response I am getting proper response from the url but response.status
is giving me 0
and my response
looks weird like:
body: null
ok: false
and so on...
I don't know what is wrong in here because my api is called and even I am getting response but I am unable to catch the response.
Is it I have to wait for api to complete and process further? Like waiting for fetch if yes then how can I do it?