Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!