hey guys can anyone help me with some array problems? trying to get MinPrice from quotes(the array is in the link below) i dont know why my code routes.map is undefined and also d.quotes.MinPrice,
can someone plz help sorry for the constant questions
fullcode: https://codesandbox.io/s/green-butterfly-00fyh?file=/src/components/ApiData.js:333-437
array: https://imgur.com/F3KVxbK
I can’t get your code to work. And I would suggest capturing some good data and saving that in a json file so it can be used for stuff like this. But looking at your code:
let d = apiDataArr.map((d) => d.Quotes.MinPrice);
But, looking at your image of the console, I see a lot of errors. There aren’t labels on your console.log so I can’t tell what all the data is.
But I see "Cannot read property ‘map’ of undefined’ That is telling me that on line 10, res.Routes is undefined
. This is consistent with the console.log on the line before. So, that makes the big, unlabelled data at the end of your next line just mystifying.
But, assuming that that data object is being logged out on line 11, so that is what is being received at line 18, why are you trying to turn it into an array? It appears to be an object. What happens when you feed an object to Array.from? You get an empty array, which exactly what the console.log on line 19 keeps reporting. So, don’t try to turn it into an array. If I’m understanding the structure of your data correctly, your array is just at apiInfo.Quotes, and you just want:
let d = apiInfo.Quotes.map((d) => d.MinPrice);
1 Like
thanks for the detailed answer man, i didnt know that well about the object thing and I mindlessly made it into a array cuz last time i had an error where i needed to convert it. Thanks again !