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.');
});