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

152
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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