[{"id":1,"name": "1"}, {"id":2,"name": "2"}]
const [data, setData] = useState([])
useEffect(() => {
fetch("http://localhost:5001/xxx")
.then(response => setData(response))
.catch(error => console.log(error))
})
return (
{
data.map(item =>
<div>{ item }</div>
)
}
useEffect(() => {
fetch("http://localhost:5001/xxx")
.then(data => data.json())
.then(response => setData(response))
.catch(error => console.log(error))
}, []);