Created
July 12, 2022 16:16
-
-
Save estevam5s/6dd98a6774a3c28f18d1615c4df00db6 to your computer and use it in GitHub Desktop.
callback.js
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
function asyncFunction(params, callback, err) { | |
var response = // requisição assíncrona | |
if (response.status === true) { | |
callback(response.data); | |
} else { | |
err(response.data); | |
} | |
} | |
asyncFunction( | |
params, | |
function(response) { | |
console.log('Sucesso!'); | |
}, | |
function(err) { | |
console.log('Erro!'); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment