Skip to content

Commit a83e492

Browse files
committed
Commit changes
1 parent 2cfbada commit a83e492

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

09_advance/01_promise.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,36 @@ const promiseFour = new Promise(function(resolve, reject){
5151
}).catch(function(error){
5252
console.log(error);
5353
}).finally(() => console.log("The promise is either resolved or rejected"))
54+
55+
async function consumePromiseFive(){
56+
try {
57+
const response = await promiseFive
58+
console.log(response);
59+
} catch (error) {
60+
console.log(error);
61+
}
62+
}
63+
64+
consumePromiseFive()
65+
66+
// async function getAllUsers(){
67+
// try {
68+
// const response = await fetch('https://jsonplaceholder.typicode.com/users')
69+
70+
// const data = await response.json()
71+
// console.log(data);
72+
// } catch (error) {
73+
// console.log("E: ", error);
74+
// }
75+
// }
76+
77+
//getAllUsers()
78+
79+
fetch('https://api.github.com/users/hiteshchoudhary')
80+
.then((response) => {
81+
return response.json()
82+
})
83+
.then((data) => {
84+
console.log(data);
85+
})
86+
.catch((error) => console.log(error))

0 commit comments

Comments
 (0)