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

122
Vistas
response is working but result is undefined

I have a simple POST request using fetch()

fetch('/login', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({ email: 'test@gmail.com', password: 'test' }),
    })
      .then((response) => {
        response.json();
      })
      .then((result) => {
        console.log(result);
      });

the response is valid and gives the JSON that I am expecting { 'id':1 } but the result just returns undefined every time. Have I written something incorrectly or am I missing something really simple?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

try return response on the first then:

.then((response) => {
   return response.json();
})
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