-
Hey everybody, Sorry for the amateur question. The data I receive from an API has nested objects:
I can pass the Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Answered by
harshcut
Aug 31, 2021
Replies: 1 comment 1 reply
-
You could use the const fetchData = [
{ name: "Item 01", stats: { average_price: "13.20" } },
{ name: "Item 02", stats: { average_price: "17.50" } },
];
const newData = fetchData.map((item) => ({
name: item.name,
average_price: item.stats.average_price,
})); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
sesto-dev
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could use the
map
function to create a new array, then pass the new array to thedata
prop.