Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to fix 'TypeError: Cannot read property 'map' of undefined' when using Axios to fetch data from an API in ReactJS?

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

enter image description here

>Solution :

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"]'

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading