-
-
Save gaurang847/b2191b7a88547aeaa715f6f0be0268ee 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
//normally calling an async function | |
get_value_from_DB(function(err, data){ | |
if(err) | |
//handle error | |
else | |
//work with data | |
}) | |
//converting async function to promise and calling it | |
new Promise(function(resolve, reject){ | |
get_value_from_DB(function(err, data){ | |
if(err) reject(err); | |
else resolve(data); | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment