Answer the question
In order to leave comments, you need to log in
How to pull data from backend?
There is data from the back:
Here is how I want to take this data:
[{"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>
)
}
Answer the question
In order to leave comments, you need to log in
useEffect(() => {
fetch("http://localhost:5001/xxx")
.then(data => data.json())
.then(response => setData(response))
.catch(error => console.log(error))
}, []);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question