I want to assign the value returned from an async function to a variable, but I am getting a promise instead of a value even do I am awaiting for the promise in the async function.
import axios from "axios";
async validateName(userName) {
const url = "abc/xyz";
try {
const response = await axios.get(url);
return response;
} catch(err) {
return false;
}
}
const validate = validateName(userName);
console.log("validate:", validate); // outputs Promise {<pending>}, but I am expecting the actual value which is true or false;
Please suggest any change I need to make as I am new to async await.