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

293
Vistas
javascript, nodejs, requestify timing

What do I have to do to make this work? I've proven the GET is returning successfully and I'm receiving the res.body I'm expecting.

But of course x is 'undefined' because the call to getSometing() isn't going to wait on requestify()

var x = getSomething();

function getSomething() {
    requestify.get('url')
        .then(function res) {
            return(res.body);
        })
        .fail(function err) {
            return("something happened");
        });
}
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I went with:

var x = getSomething();

function getSomething() {
    return new Promise(resolve => {
        requestify.get('url')
            .then(function res) {
                resolve(res.body);
            })
            .fail(function err) {
                resolve("something happened");
            });
    });
}

This guarantees x will have something; rain or shine; and that is exactly what I want.

over 4 years ago · Santiago Trujillo Denunciar
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