I have this
import axios from 'axios'
export const fetchData = async () => {
const URL = 'url here'
const { data } = await axios.get(URL)
return data
}
At this point, I get the data I want, an array of objects
Array(6) [ {…}, {…}, {…}, {…}, {…}, {…} ]
Yet in another file when I use the fetchData function:
const DisplayPeople = () => {
const data = fetchData()
console.log(data);
return (
<div>DisplayPeople</div>
)
}
Here, what I get is instead:
Promise { <state>: "pending" }
<state>: "fulfilled"
<value>: Array(6) [ {…}, {…}, {…}, … ]
<prototype>: Promise.prototype { … }
Why is it like this? I just want to get the same result as I get in the fetchData function