Chrome The message port closed before a response was received
发布时间:2023-05-31浏览次数:0
支持注册ChatGPT Plus的OneKey虚拟卡
绑定Apple Pay、Google Pay、支付宝和微信支付进行日常消费
注册和了解更多 ->
silver
Add a return true. It will force chrome to wait for the response.
添加一个返回true。它将迫使chrome等待响应。
chrome.extension.onMessage.addListener((request, sender, sendResponse) => {
// Look up a term from the dictionary using the Ajax API.
const lookupURL = `http://dictionary-lookup.org/${request.arg}`;
sendRequest(lookupURL)
.then(resp => {
sendResponse(resp || '{}');
})
.catch(error => {
sendResponse('{}');
});
return true; // Inform Chrome that we will make a delayed sendResponse
});
扫描二维码查看更多内容