so I have an API that I am calling from the front end and so in order to get the value of it I put in in a promise function that way I would ensure that it would not return until it was completed like so
const findCurrentUser = () => UserApi.getCurrentUser().then(res => res);
I then tried to just get the value out calling a variable with the return from the top function like so
const currentUser = findCurrentUser().then(res => res)
and I still got a promise
so then I did some research and they said I had to call the
currentUser.then(res => res)
and then I should be able to get the result
This is true when I do it like this
currentUser.then(res => console.log(res))
but as soon as I try to stick that return value into a variable like this
const currentUserObject = currentUser.then(res => res);
I get another promise.
I also tried it with async/await in the first function like this
const findCurrentUser = async () => {
await UserApi.getCurrentUser();
};
and that didn't work either