Working with Fetch API to get the data from service after posting formdata, which is not return any proper data. Always returns opaque response. But i need cross-origin to get/post the data. here is my code.
fetch('http://localhost:3000/default/index', {
method: 'POST',
body: formData,
mode: 'no-cors',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
}
}).then(function (response) {
return response.json();
}).then(function (data) {
debugger;
}).catch(function (error) {
console.log(error);
});
After running the script got this,
I need the proper response which returned from server side.
NOTE: In Network tab i can see the proper stringified response, still i can't get it in then function response.