Answers for "promise with params"

0

promise with params

function someFunction(username, password) {
  return new Promise((resolve, reject) => {
    // Do something with the params username and password...
    if ( /* everything turned out fine */ ) {
      resolve("Stuff worked!");
    } else {
      reject(Error("It didn't work!"));
  	}
  });
}

someFunction(username, password)
  .then((result) => {
    // Do something...
  })
  .catch((err) => {
  	// Handle the error...
  });
Posted by: Guest on August-14-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language