Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to parse arguments to a promise in javascript

const some_function = (username, password) =>
{
 return new Promise((resolve, reject) =>
 {
  /*stuff using username, password*/

  if ( /* everything turned out fine */ )
  {
   resolve("Stuff worked!");
  }
  else
  {
   reject(Error("It broke"));
  }
 });
};

some_module.some_function(username, password).then(uid =>
{
 // stuff
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #parse #arguments #promise #javascript
ADD COMMENT
Topic
Name
6+2 =