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

136
Views
POST request generates failed to fetch

I'm having problems making a POST request through the fetch API from javascript and I get the following error: TypeError: Failed to fetch at fetchCallImpp at window.fetch The code is the following:

const agregarCafetalDB = (nombre) => {
    const data = {
        "nombre": `${nombre}`,
    };
    const requestOptions = {
        method: 'POST',
        body: JSON.stringify(data),
        redirect: 'follow',
        mode: 'cors',
        headers: {
            'Content-Type': 'application/json',
            'Access-Control-Allow-Origin': '*'
        },
    };
    fetch(url, requestOptions)
        .then(response => response.json())
        .then(result => console.log(result))
        .catch(error => console.log('error', error));
}

btnAgregar.addEventListener('click', (e) => {
    agregarCafetalDB(cafetal.value)
});

I would like you to help me solve the error thank you very much in advance

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Does the same error shows in other browsers? fetch is ES6 Javascript, maybe the browser you are using doesn't support it.

fetch(url, requestOptions)

Also, make sure that variable 'url' is defined.

about 4 years ago · Juan Pablo Isaza Report
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!