Google chrome扩展程序:chrome.runtime.sendmessage

时间:2019-03-16 10:06:30

标签: google-chrome

防止跨源读取阻止(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。

0 个答案:

没有答案