I'm retrieving data from an API that parses a currency in the URL (using this format: https://api.coingecko.com/api/v3/simple/price?ids=${crypto}&vs_currencies=${currency}
) and it returns data like this
{
"bitcoin": {
"aud": 44768
}
}
The JSON format changes depending on the url. How do I find the price when the currency is changed? Thanks.
I'm going to assume that you have crypto
and currency
already since you are computing a request URL.
https://api.coingecko.com/api/v3/simple/price?ids=${crypto}&vs_currencies=${currency}
So when you are processing the response I suppose you can use these as keys to access into the response object.
const value = response[crypto][currency];
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments