Pipelining in javascript
By using $.flatMap() you also get error handling for free. If the request to fetch a post fails or the request to fetch the post’s author fails the promise that this version of authorForPost() returns will also fail with the appropriate failure values.
Read more: Link - Promise Pipelines in JavaScript