I’m trying to fetch this online data as table using array map, how I can do it?
import React, {useEffect, useState} from "react";
import './App.css'
function App() {
const [data, setData] = useState([]);
console.log(`this data before fetch: ${data}`);
useEffect(() => {
fetch('https://jsonplaceholder.typicode.com/todos')
.then(response => response.json())
.then(data => setData(data))
.catch(error => console.error(error));
}, []);
return (
<div>
<div className={"nothing"}>
<h3>{JSON.stringify(data)}</h3>
</div>
</div>
);
}
export default App;
I was fetching the data as 1 object:
enter image description here
Now, I want to fetch it as table using map, can I? With detail explanation as you can,
Thanks!