Question:
If I convert innerHTML part to that:
[object Object][object Object][object Object][object Object]
Where I am making mistake? and how can I push to front this json data with cards?
Example json data
Answer:
Just remove thedocument.getElementById('cards').innerHTML +=
. You don’t want that. ReactJS should do the DOM update. And, you should not return from the fetch
function. Create a state, and you can use it to render the JSX..
Here is the properly structured Functional Component
for you.useEffect
hook to fetch the items when the component is mounted on DOM
. And we are verifying if the item
object is not empty before renderingIf you have better answer, please add a comment about this, thank you!