If we add async to any function declaration, it simply means return a promise by that function.
// If we add async to any function declaration, it simply means return a promise by that function.
// async function always returns a promise if you return something by the use of "return keyword"
const asyncFun = async () => {
return "It is async function, it returns promise only";
}
// If you return Promise explicitly, no matters it returns a promise same as above function.
const asyncFun = async () => {
return Promise.resolve("It is async function, it returns promise only");
}
// Both of function retrun same promise and get the data by the use of "then".
var asyncData2 = asyncFun2().then(data => {
console.log(data);
});
// Result is : It is async function, it returns promise only