我想使用抓取API從URL獲取整個HMTL文檔。爲什麼提取返回狀態= 0的響應?
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)=> {});
在chrome中運行代碼,它觸發一個請求並在chrome網絡中返回html。但獲取資源收益:
爲什麼狀態,我怎樣才能得到正確的資源像什麼的鍍鉻代理店?
狀態0是依賴於庫的,函數庫是'fetch'函數? – tcooc
'fetch'是一個本地函數(現在)。 – Brian