-
-
Save uno-de-piera/887abc9e1495c2ca01c15de78cc492a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class User { | |
userPromise() { | |
return new Promise((resolve, reject) => { | |
if(1 === 1) { | |
return resolve([{name: 'Iparra'}]) | |
} | |
return reject({msg: 'error'}); | |
}) | |
} | |
} | |
let user = new User(); | |
let promise = user.getUserPromise(); | |
promise.then(user => { | |
console.log(user[0]); //{name: 'Iparra'} | |
}).catch(error => { | |
console.log(error); //Uncaught {msg: "error"} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment