I want to do a promise chain like this one:
promise1
  .then(resp => {
    ... // some code to run after promise1 
    if (xxx) {
      return promise2() // call promise2
    } else {
      // I want to stop the promise chain here
    }
  })
  .then(resp => {
    ... // some code to run after promise2 
  })
  .catch(error => {
    ... // I only want to handle error in catch function
  })
What is the best way to create optional promise chains?
What is the best way to stop promise chains?
