Skip to content

Commit 277eb09

Browse files
Update promises.js
1 parent 5688ab0 commit 277eb09

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

part9_Advanced/promises.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,19 @@ myPromise.then((data) => {
6060
console.log(`error fetching data ${error}`);
6161
})
6262
console.log(myPromise);
63+
64+
65+
// Creating another promise
66+
const p = new Promise((resolve, reject) => {
67+
setTimeout(() => {
68+
resolve("Promise resolved");
69+
}, 4000);
70+
})
71+
72+
p.then(() => {
73+
console.log('data fetched successfully');
74+
}).catch(() => {
75+
console.log("Error fetching data");
76+
}).finally(() => {
77+
console.log("Program completed");
78+
})

0 commit comments

Comments
 (0)