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

174
Visualizações
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
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