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

127
Vistas
Post request using node-fetch not returning response

I'm new to using node-fetch and catch figure out why I am not getting any response data to print to the console.

Im using a function to generate firebase user auth tokens for testing but I'm not getting any response whereas in postman my requests with the same data are returning what I want. As you can see I've even hard coded the data into the body and still its not returning anything.

async function firebaseSetupAuth(){
  const token1 = admin.auth().createCustomToken("xKdXw06u2tUVE72ETrJVwevCNQo1")
  const token2 = await token1
  token = token2
  const url = "https://identitytoolkit.googleapis.com/v1/accounts:signInWithCustomToken?key=AIzaSyBoKaBKWe9x2LS_n5AHCIEM-5AB_dC99mg"
  const fetchBody = {"token": token,"returnSecureToken":true }
  console.log(JSON.stringify(fetchBody))
  const response1 = fetch(url,{
    method: "post",
    body: fetchBody,
    headers: {'Content-Type': 'application/json'}
  })
  const response2 = await response1
  console.log(response2)
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to return the result of fetch

.then((customToken) => {
    return fetch(url,{ // return on this line
      method: "post",
      body: JSON.stringify(/*stuff*/),
      headers: {'Content-Type': 'application/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