code looks like this, not sure how to read response data. Any idea?.
var url = 'http://www.bbc.co.uk/sport/football';
fetch(url, {
mode : 'no-cors'
}).then(function(response) {
console.log(response);
});
Response Object
no-cors. Prevents the method from being anything other than HEAD , GET or POST , and the headers from being anything other than simple headers. If any ServiceWorkers intercept these requests, they may not add or override any headers except for those that are simple headers.
How do you remove CORS? To get rid of a CORS error, you can download a browser extension like CORS Unblock ↗. The extension appends Access-Control-Allow-Origin: * to every HTTP response when it is enabled. It can also add custom Access-Control-Allow-Origin and Access-Control-Allow-Methods headers to the responses.
How do I return a response on Fetch? Use the fetch() method to return a promise that resolves into a Response object. To get the actual data, you call one of the methods of the Response object e.g., text() or json() . These methods resolve into the actual data.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With