Skip to content

Instantly share code, notes, and snippets.

@gaurang847
Created June 19, 2019 19:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
//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