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

170
Views
Using a graphql value in a variable issues?

I created the following (using supertest) and placed in a function (removed imports etc for brevity)

module.export = {
addThing: async function(title, done) {
    const someGraphQL = `mutation {.....}`
    
    let the_id = ""

    request
    .post("/graphql") 
    .send({
        query: someGraphQL
    })
    .set("Accept", "application/json")
    .expect(200)
    .end((err, res) => {
        if (err) return done(err);
        the_id = Prmise.resolve(res.body.data.id);
        console.log(res.body.data.id)
    })
    console.log(the_id)
    return the_id
  }
}

When I call this I can see the console.log with the "res.body.data.id", but not the one in the variable.

I thought this may have been async type behaviour, but as I always see that console log for the res.body.data.id (but not for the variable (no matter where I put the variable) I am confused?

about 4 years ago · Juan Pablo Isaza
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!