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

153
Vistas
How to get the objects from a request url module function to another function

So, i was working in on multi API project where ,there's one part where one had to enter the address , for where you want to get the weather outputs, and i am stuck in a part where i can take the API values of long. and lat. converted out of a address string and pass it to a API for weather outputs.as i can't access the API output of one to another. The request url is like this:

request({url:url,json:true}, (error,response) => { 
   console.log(response.body.current.weather_descriptions[0] +' The temperature is '+chalk.inverse(response.body.current.temperature)+' but it feels like '+ chalk.inverse(response.body.current.feelslike))
})
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

ok, i found an answer using call back function, i have answered below the code.

const geoCode = (geoUrl, callback) => {
    request({url:geoUrl,json:true}, (error,response) => { 
        if(error)
        {
            console.log('Unable to connect to the server.....')
        }
        else{
    callback(undefined,{
        latitude:response.body.data[0].latitude,
        longitude:response.body.data[0].longitude
    })
}
        
        
        })
}

geoCode(geoUrl,(error,data) =>
{
    var url = 'youur api'
    url = url+data.latitude+","+data.longitude
// console.log(url)

    request({url:url,json:true}, (error,response) => { 
       
        if(error)
        {
            console.log('Unable to connect to the server.....')
        }
        else{
            console.log(response.body.current.weather_descriptions[0] +' The temperature is '+chalk.inverse(response.body.current.temperature)+' but it feels like '+ chalk.inverse(response.body.current.feelslike))
}
        
        
        })
})

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