Recently, I received a complex object from an API:
let curr = {
"base_currency_code": "EUR",
"base_currency_name": "Euro",
"amount": "10.0000",
"updated_date": "2024-04-14",
"rates": {
"USD": {
"currency_name": "United States dollar",
"rate": "1.0649",
"rate_for_amount": "10.6489"
},
"AUD": {
"currency_name": "Australian dollar",
"rate": "1.6444",
"rate_for_amount": "16.4443"
},
"CAD": {
"currency_name": "Canadian dollar",
"rate": "1.4669",
"rate_for_amount": "14.6690"
}
},
"status": "success"
}
I am now looking to transform this data into a sorted array of objects like this :
let curr = [
{
"id": "AUD",
"currency_name": "Australian dollar",
"rate": "1.6444",
"rate_for_amount": "16.4443"
},
{
"id": "CAD",
"currency_name": "Canadian dollar",
"rate": "1.4669",
"rate_for_amount": "14.6690"
},
{
"id": "USD",
"currency_name": "United States dollar",
"rate": "1.0649",
"rate_for_amount": "10.6489"
}
]
I have been attempting various methods to make it suitable for a Flatlist in react-native. However, I haven't had much luck so far. Any advice or suggestions would be greatly appreciated!