I'm trying to learn how to use axios from this site: Asynchronous Javascript using Async - Await
async function getGamerDescription() {
const text = await axios.get(`/api/gamer/${id}/gamerBio`);
return text.data;
}
console.log("bio: ", getGamerDescription());
gives me:
bio: Promise {<pending>}
If I put the console.log INSIDE the getGamerDescription() function, then it writes out the bio text that I need.
But I need to assign the bio text to a variable so I can display it on my website.
Is there a way to do that?
I found some other SO questions:
My call async/await returns a Promise {} in my actions
But they didn't help.
I just want to be able to get the value so I can assign it to a variable.