Created
April 6, 2019 18:45
-
-
Save khaosdoctor/a6e72236701dc27b3e3912d3c5372a44 to your computer and use it in GitHub Desktop.
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
// Criando uma promise | |
const p = new Promise((resolve, reject) => { | |
try { | |
resolve(funcaoX()) | |
} catch (e) { | |
reject(e) | |
} | |
}) | |
// Executando uma promise | |
p | |
.then((parametros) => /* sucesso */) | |
.catch((erro) => /* erro */) | |
// Tratando erros e sucessos no then | |
p | |
.then(resposta => { /* tratar resposta */ }, erro => { /* tratar erro */ }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment