skip to Main Content

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

enter image description here

enter image description here

2

Answers


  1. Assuming you’re getting the response in a variable called res such that:

    let res = {
      "prices" : {
        "BTC/USDT" : 27071.28
      },
      "ms" : 3
    }
    

    Then to get prices you can use: res.["prices"].["BTC/USDT"]

    So here at line 40 you can use const req = '${btcToUsd}.["BTC/USDT"]'

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search