Skip to content

Instantly share code, notes, and snippets.

@sht5
Created April 30, 2017 20:49
Show Gist options
  • Save sht5/af5223dc7c1be68ddbc49ad32d2648bb to your computer and use it in GitHub Desktop.
Save sht5/af5223dc7c1be68ddbc49ad32d2648bb to your computer and use it in GitHub Desktop.
new promise wrapping example
const methodReturningPromise = () => {
return new Promise((resolve, reject) => {
asyncMethodToFetchData(params, (err,result) => {
if(err){
reject(err); // return rejected promise to method caller
};
else{
resolve(result); // return fulfilled promise to method caller
}
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment