Skip to content

Commit a3f0692

Browse files
refactor: async await
1 parent ac27886 commit a3f0692

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

23_asynchronous_javascript/05_async_and_await/01_async_and_await.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,20 @@ async function myAsyncFunction() {
3030
const promise = function () {
3131
return new Promise((resolve, reject) => {
3232
setTimeout(() => {
33-
resolve("Data fetched successfully!");
33+
// resolve("Data fetched successfully!");
3434
reject("Error fetching data");
3535
}, 2000);
3636
});
3737
};
3838

3939
async function consumePromise() {
4040
try {
41+
console.log("Fetching data...");
4142
const response = await promise();
4243
console.log(response);
4344
} catch (error) {
4445
console.log(error);
4546
}
4647
}
4748

48-
consumePromise();
49+
consumePromise();

0 commit comments

Comments
 (0)