The then method registers reactions on a Promise and returns another Promise, allowing fulfillment values and errors to move through a composed asynchronous workflow. section 8.2.2 section 8.2.3
Use then to structure transformations and preserve the intended flow:
- Chain calls when each transformation should receive the preceding result: Promise.resolve('aabbcc').then(unique).then(join).then(toUpper). section 8.2.3
- Return nested promises from handlers so their results and failures rejoin the main chain; returned promises are flattened automatically. section 8.2.2 section 8.2.3
- Attach catch for errors that travel through the linked chain, or recover with a default value when appropriate. section 8.2.3
A chain is not multiple handlers on one promise
const p = Promise.resolve('aabbcc'); p.then(unique); p.then(join); p.then(toUpper); These calls all receive the original value and create separate promises. Chaining the returned promise instead—p.then(unique).then(join).then(toUpper)—passes each transformed result to the next step. section 8.2.3
Listing 8.4 Fully linked chain of promises
Promise.resolve('aabbcc')
.then(unique) #1
.then(join) #1
.then(toUpper); #1
A compact listing shows the intended unidirectional transformation pipeline. section 8.2.3




