Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const sampleCallBack = (callback) => {
- setTimeout(() => {
- callback('This is an error', undefined)
- }, 2000)
- }
- sampleCallBack((error, result) => {
- if (error) {
- return console.log(error)
- }
- console.log(result)
- })
- const samplePromise = new Promise((resolve, reject) => {
- setTimeout(() => {
- resolve('Hi there')
- //reject('Hi there')
- }, 2000);
- })
- samplePromise.then((result) => {
- console.log('success', result)
- }).catch((error) => {
- console.log('error', error)
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement