0
async function getPrice () {
 //console.log("waiting");
const price = await  promise.all([axios.get('https://api.coingecko.com/api/v3/simple/price?ids=shiba-inu&vs_currencies=usd'),axios.get('https://api.coingecko.com/api/v3/simple/price?ids=dogecoin&vs_currencies=usd')]).then(results =>{
                 return results[0].data.shiba-inu.usd / results[1].data.dogecoin.usd;}).then(pricedata =>{
                 return pricedata;
    });         
  return price ;
};

the json file from : https://api.coingecko.com/api/v3/simple/price?ids=shiba-inu&vs_currencies=usd contains :

{
  "shiba-inu": {
    "usd": 0.00002847
  }
}

this is the error:

return results[0].data.shiba-inu.usd / results[1].data.dogecoin.usd;}).then(pricedata =>{

ReferenceError: inu is not defined.

I don't know how to properly get the shiba-inu price , I have tried to put it between () or ''. the code is runnig well my only problem is with this composed name(shiba-inu) if I try tether or something else it goes well (replacing api and results[0].data.tether.usd)

Anurag Srivastava
  • 13,226
  • 4
  • 25
  • 40

0 Answers0