export const isLoginValid = async token => {
try {
let result = await axios.post(API_URL + "/verify", null, {
headers: { Authorization: "Bearer " + token }
});
return await result.data;
} catch (error) {
console.log("Unable to verify");
return false;
}
};
I am using the code above to check if a user's login is valid. However, the return statement returns a Resolved Promise with the data inside the promise. Data needs to return true or false. Is there a way to unwrap the promise and just return the data? I'm fairly new to async/await. I've tried suggestions found in here but no matter what i try it returns a promise.
Edit
By the way, this is not a duplicate, the suggested answer is not what my problem was. I had trouble getting the value from a async/await call using axios since it kept returning a promise.
This helped me get the value from an async/await axios called.