Skip to content

Instantly share code, notes, and snippets.

@uno-de-piera uno-de-piera/User.ts Secret
Created Jan 21, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.