JS: Nested promises : <p>I do not understand how to chain promises:</p>

<p><code>getUser</code> is a promise function and also <code>search</code> is a promise function. <code>getUser</code> will return a language value.</p>

<p>With this data is not an array value, which should be returned by the <code>search</code> function</p>

<pre><code>getUser(userId)
  .then(({ language }) =&gt; {
    const data = search('content', language)
    res.send(200, {
      content: data,
      user: { language }
    })
  })
  .catch((error) =&gt; next(error))
</code></pre>
