Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

send variable to javascript promise

var some_function = function(username, password)
{
 return new Promise(function(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(function(uid)
{
 // stuff
})
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #send #variable #javascript #promise
ADD COMMENT
Topic
Name
4+6 =