fetch("https://c.y.qq.com/v8/fcg-bin/fcg_myqq_toplist.fcg", {
mode: 'cors'
}).then(function (response) {
if (!response) {
throw new Error('fail to get data');
} else {
console.log(response);
}
}).catch(err => {
console.error(err, '网络问题')
});
这样写会有问题:failed to fetch https://c.y.qq.com/v8/fcg-bin/fcg_myqq_toplist.fcg
将mode改为'no-cors'会返回type为opaque的response,应为相应不能阅读。