Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

114
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda