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

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

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 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