Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

116
Views
Getting undefined from background script fetch on chrome

I get undefined from fetch only on chrome, while it works on firefox.

// content script
async function fetchAPI(link, init = {}) {

    let res = await chrome.runtime.sendMessage({
        url: link,
        config: init
    })

    return res;
}

fetchAPI(`some link`);

// background script
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
    console.log(request);

    return new Promise((resolve) => {
        fetch(request.url, request.config)
            .then(res => {
                res.json()
                    .then(value => {
                        resolve(value);
                    });
            });
    });
});

Sorry about the messy background script code. I don't think I have much more to explain.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!