How does promise chaining work? code example

Example 1: how to implement a promise with daisy chaining in angular

private firstAction():Promise<any> {
  return new Promise<any>(
    (resolve, reject) => { ... }
  );
}
private secondAction():Promise<any> {
  return new Promise<any>(
    (resolve, reject) => { ... }
  );
}
execute() {
  this.firstAction().then(
    (firstResult:any) => this.secondAction().then(
      (secondResult:any) => { ... }
    );
  )
}

Example 2: .then javascript

const promise2 = doSomething().then(successCallback, failureCallback);