My cars.json
"cars": [
{
"id": 1,
"name": "Kia K5",
"seats": 4,
"price": 23690,
"color": [
{
"name": "Black",
"bonusPrice": 0
},
{
"name": "Gray",
"bonusPrice": 0
},
]
},
And My fetch in App.js
fetch('http://localhost:8000/cars', {
method: 'GET',
headers : {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
})
.then((res) => res.json())
.then(cars => {
setCars(cars)
});
}, [])
but I got an error:
Unhandled Rejection (Error): Objects are not valid as a React child (found: object with keys {name, bonusPrice}). If you meant to render a collection of children, use an array instead.
Where am I wrong? Help me. Thank you all.