when getting req from API .. res => this enter image description here
when added to my project like that enter image description here
send me this error enter image description here
when getting req from API .. res => this enter image description here
when added to my project like that enter image description here
send me this error enter image description here
2
Answers
Assuming you’re getting the response in a variable called
res
such that:Then to get prices you can use:
res.["prices"].["BTC/USDT"]
So here at line 40 you can use
const req = '${btcToUsd}.["BTC/USDT"]'
You are not accessing the object key correctly. Given that you have a slash in the object key, you will need to do something like this:
responseObject.prices[“BTC/USDT”]
.If I were you, I would update the name of the key to something like
btc_usdt
, so that way you could access the object like this:responseObject.prices.btc_usdt
.