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

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