Explore tweets tagged as #PromiseExample
@JunaidArif24
Junaid Arif
2 years
👉 Here's an example of chaining a "then" method onto our promiseExample:. promiseExample.then((value) => {. console.log(value);.}).catch((error) => {. console.log(error);.});.
1
0
1
@JunaidArif24
Junaid Arif
2 years
👉 Here's an example of creating a Promise in JavaScript:.const promiseExample = new Promise((resolve, reject) => {. setTimeout(() => {. resolve('Promise fulfilled!');. }, 2000);.});.
1
0
1
@JunaidArif24
Junaid Arif
2 years
👉 In the example above, we log the fulfilled value of our promiseExample to the console. If there was an error and the Promise was rejected, we would log the error instead.
1
0
1