0.4.6.1: Async Await
Learning Objectives
Introduction
// myFunc returns the return value of myFunc, currently undefined
const myFunc = () => {
axios.get("foobar.com").then((data) => {
// Do something with data after response received
console.log(data);
});
};// myFunc returns a promise due to the async keyword
// The promise resolves to the return value of myFunc
const myFunc = async () => {
const data = await axios.get("foobar.com");
// Do something with data after response received
console.log(data);
};