Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!