How to get data using fetch API with no-cors mode?

the code looks like this, not sure how to read the 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

+6
source share
2 answers

You can not.

If the source does not support CORS, you cannot directly receive response data. That the entire no-cors ... no-cors allows you to use the answer in a certain way, but not actually read / access data.

+9
source

Use one of the following options, depending on the expected data:

 response.blob() response.text() response.formData() response.json() response.arrayBuffer() 
-4
source

Source: https://habr.com/ru/post/1012067/


All Articles