How should the third then in promise be written with the parameters returned by the first and second then respectively?

  node.js, question


 return r1;
 return r2;

What if such logic is to be realized?
Ruan Yifeng’s original text reads as follows:

The then method returns a new Promise instance (note, not the original Promise instance).  Therefore, the chain writing method can be adopted, that is, the then method is followed by another then method.
 getJSON("/posts.json").then(function(json) {
 }).then(function(post) {
 //   ...
 The above code uses the then method to specify two callback functions in turn.  After the completion of the first callback function, the returned result will be taken as an argument and passed into the second callback function.

It seems that the parameters are passed layer by layer. How do I pass then of 1 and 2 to 3, or pass 2 parameters at once?


var promise = Promise.resolve(3);
 Promise.all([true, promise])
 .then(values => {
 console.log(values);  // [true, 3]
 }); …