Last active
July 11, 2017 03:00
-
-
Save mortegac/ea5f68bc8988b93c9ebfbc2d37d0703e to your computer and use it in GitHub Desktop.
Ejemplo-Promesas
This file contains hidden or 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
//DEFINICION DE PROMESA | |
var p1 = new Promise((resolve, reject) => { | |
if (true) | |
throw new Error("rejected!"); // same as rejection | |
else | |
resolve(4); | |
}); | |
//LLAMADA | |
p1.then((val) => val + 2) | |
.then((val) => console.log("got", val)) | |
.catch((err) => console.log("error: ", err.message)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment