-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpromises.js
36 lines (30 loc) · 833 Bytes
/
promises.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// const promiseOne = new Promise(function(resolve, reject){
// setTimeout(function(){
// console.log("Promise 1 resolved");
// resolve();
// }, 2000)
// })
// promiseOne.then(function(){
// console.log("Promise 1 consumed");
// })
// const promisethree = new Promise(function(resolve, reject){
// setTimeout(function(){
// resolve()
// }, 1000)
// })
const promisefive = new Promise(function(resolve, reject){
setTimeout(() => {
let error = true
if (!error){
resolve({username: "Hitesh", password: "123"})
}
else{
reject("Error: Something went wrong")
}
}, 1000);
})
async function consumepf() {
const response = await promisefive
console.log(response);
}
console.log("somerhing working");