javascript - chrome.runtime.onMessage response with async await - Stack Overflow

PHOTO EMBED

Fri May 10 2024 14:11:51 GMT+0000 (Coordinated Universal Time)

Saved by @surmamilan #javascript

chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
  (async () => {
    // async code goes here
    // ...
    const result = await getSomething();
    sendResponse(result);
  })();

  // Important! Return true to indicate you want to send a response asynchronously
  return true;
});

content_copyCOPY

https://stackoverflow.com/questions/44056271/chrome-runtime-onmessage-response-with-async-await