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

138
Visualizações
Getting value out of the function - return

I'm a bit confuse at this stage regarding the below code. I'm trying to run a script that will run indefinitely every hour. I have successfully get the right result but when I try to get that result out of price function, essentially price = result. I simply can't find the way around it.

TestScript

const axios = require('axios')
const nodeCron = require("node-cron");
async function runJob(){
    try{
        
    let price =   await nodeCron.schedule("* * * * *", async function(){ 
            let ids = ['binancecoin', 'sushi', 'solana', 'osmosis', 'pancakeswap-token', 'avalanche-2', 'quick','curve-dao-token','raydium','polkadot','truefi']
            let url = `https://api.coingecko.com/api/v3/simple/price?ids=${ids}&vs_currencies=usd`
    
            let result =  await axios.get(url).then(function(priceFeed){
                        //console.log(priceFeed.data)
                         return priceFeed.data 
                         })
            console.log(result)
                return{
                    ***result***,
                }
            }
        )
        console.log(price) <------ trying to get this equal to result
        return{
            price,
        }
    }
    catch(error){
        console.log(error)
    }
}
runJob()
about 4 years ago · Santiago Gelvez
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