防止跨源读取阻止(CORB) -Chromium小组建议在后台脚本而非内容脚本中执行获取或xhr请求。
function request() {
let fetchedData;
Chrome.runtime.sendmessage ({type: 'fetchdata'},
(res) => {
console.log(res)// The response is seen on the console
fetchedData = res;
});
return fetchedData;
}
console.log(request())//Returns undefined or nothing.
如何将返回的响应传递给变量fetchedData。