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()