</code> and <code>catch</code> methods. This feature allows us to flatten nested promises to make code more manageable.</p>
<pre><code class="lang-javascript">function searchUsers(q) {return m.request(&quot;/api/v1/users/search&quot;, {data: {q: q}})}
function getUserProjects(id) {return m.request(&quot;/api/v1/users/&quot; + id + &quot;/projects&quot;)}

// AVOID: pyramid of doom
searchUsers(&quot;John&quot;).then(function(users) {
  getUserProjects(users[0].id).then(function(projects) {
    var titles = p