Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

115
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda