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

132
Views
Errors when using the fetch function (JavaScript)

I'm working with AWS API Gateway and I'm getting the following error:

Uncaught TypeError TypeError: Failed to fetch

My API is just returning a simple JSON string. I can get a successful response with curl, Postman and testing via the AWS console. But, using JavaScript, I get an error. I suspect that AWS requires a specific header

I separated the code from the original website. Some unnecessary parts have been removed.

<script type = "text/javascript">
const GET_url = '<url>'
const POST_url = '<url>'

async function getInvokeFromAPI() {
  const response = await fetch(GET_url, {
    method: 'GET'
  });
  const data = await response.json();
}

async function postInvokeFromAPI() {
  const respone = await fetch(POST_url, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    }
  });
  const data = await response.json();
}
</script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It would be helpful to see the console output when the error happens.

But if it works with Postman and not with the fetch API, you are probably having a CORS error.

You can check this page of the MDN for more informations about CORS in case it is your error: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

If it is your error, it will be logged in the browser console in the dev tools.

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!