I have been trying to make an api call and receive the data back as an array to iterate over the array and populate react components. The problem is I am only receiving promises back, and therefore react will not let me use the map function. I am newer to react and am having trouble understanding the problem.
I am making the axios call as below:
const makeRequest = async (url) => {
return await axios.get(url).then(response => response.data);
}
And then attempting to save the array response inside a variable to be iterated over.
let data = makeRequest("someUrl");
If I have a console.log() call inside the request, I can get the array, but as soon as I try to save it to the variable I am only getting the promise. Any help would be great thank you!