I want to use fetch API to get a whole HTML document from URL.
let config = {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Accept': 'text/html',
'Accept-Language': 'zh-CN',
'Cache-Control': 'no-cache'
},
mode: 'no-cors'};
fetch('http://www.baidu.com', config).then((res)=> {
console.log(res);}).then((text)=> {});
When I run the code in chrome, It triggers a request and returns html in the chrome network tab. but fetch res return:
Why status is 0 and how can I get the correct res like the one in the chrome network ?