0

I am new to Chrome extensions and javascript but I want to get the number of unread emails from Google's Feed Atom enter link description here. I want the background.js of my Chrome extension to read the contents of the tab without the tab ever being opened. The below code does visit the page properly as the "HERE" print out does print out. But then it prints this error: "something went wrong. (anonymous) @ background.js:7 Promise.catch (async) (anonymous) @ background.js:6"

P.S. The printouts are in the service workers' console.

fetch("https://mail.google.com/mail/u/0/feed/atom").then(function (response) {
    console.log("HERE")
    return response.json();
}).then(function (data) {
    console.log(data);
}).catch(function (err) {
    console.warn('Something went wrong.');
});
Russell Hertel
  • 121
  • 3
  • 14
  • Use [devtools for the background script (service worker)](/a/10258029) to debug the code and inspect the value of `err`. You can do it by setting a breakpoint inside `catch` function. – wOxxOm Jun 11 '23 at 16:15

0 Answers0