My code looks like this. How do I read the response data?
var url = 'http://www.bbc.co.uk/sport/football';
fetch(url, {
mode : 'no-cors'
}).then(function(response) {
console.log(response);
});
My code looks like this. How do I read the response data?
var url = 'http://www.bbc.co.uk/sport/football';
fetch(url, {
mode : 'no-cors'
}).then(function(response) {
console.log(response);
});
You can't.
If the origin doesn't support CORS, you can't actually get the response data directly. That's the whole point of no-cors... allowing you to use the response in certain ways, but not actually read/access the data.
Use one of below, depending what data you expect:
response.blob()
response.text()
response.formData()
response.json()
response.arrayBuffer()
no-cors.