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

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