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

113
Views
When I fetch using GET method I receive an error 502

When I try to fetch using GET I recieve an error 502 but when I fetch using POST i recieve the response.

Lambda:

const headers = {'Content-Type':'application/json'}


exports.handler = async function(event) {
    return {
      statusCode: 200,
      headers: {
        headers
      },
      body: JSON.stringify({"ok":"ok"})
    }
};

Fetch:

fetch("https://n3bvznv385.execute-api.us-east-2.amazonaws.com/dev/juegos", {
            method: 'GET',
            headers: {
                'Content-Type': 'application/json',
                'Accept': 'application/json',
                'authorizationToken' : '123',
            }
        }).then(response => response.json())
            .catch(error => console.error('Error:', error))
            .then(response => console.log(JSON.parse(response.body)));

Error using GET Success using POST

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

0

API Gateway expects the following response format from your Lambda when you are using Proxy Integration:

{
    "isBase64Encoded": true|false,
    "statusCode": httpStatusCode,
    "headers": { "headerName": "headerValue", ... },
    "multiValueHeaders": { "headerName": ["headerValue", "headerValue2", ...], ... },
    "body": "..."
}

You are, however, passing a nested object as headers as your code resolves to this:

headers: { {'Content-Type':'application/json'} }.

Try to include possible headers like this instead:

exports.handler = async function(event) {
    return {
      statusCode: 200,
      headers: headers,
      body: JSON.stringify({"ok":"ok"})
    }
};
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!