Started react, issue with first project (handling Async HTTP call)

I am using the api to get information for a project i am working on but when i run a function which gets information from the api called getStats function it does not work in the first search and shows up as undefined in the console but when i search for a second time the array from the api shows up in the console this is an issue because when I try to map over the array given I get an error that says it cannot map over undefined. I am assuming the issue is due to the fact that this function needs to wait for another function to get information from the api called getPlayerId then i use the playerId to run getStats how can i run getStats only after getPlayerId has run I will put a screenshot of my code below in order to better illustrate my issue

I want the second item in the console to show without showing undefined in the first search hopefully this makes sense