title: How to perform an api call from a middleware in express - NodeJS
body: <p>First of all, I'm working with express in NodeJS.<br />
  I want to create an API call for updating the user's personal account informations.<br />
  Before doing this I should ask the user for the password for more security, this operation will be handled in this middleware <code>isPasswordCorrect </code> inside the request:</p>
  <pre><code>const isPasswordCorrect = (req, res, next) =&gt; {
      const password = req.password
      // perform the login call, to confirm the user identity
      // if password is correct call next()
  }
  </code></pre>
  <p>I already created this endpoint to log in:</p>
  <pre><code>router.post('/login', (req, res) =&gt; {
      const { login, password } = req.body
      // do some logic for checking if the login data are correct
      res.json({&quot;accessToken&quot;: accessToken})
  })
  </code></pre>
  <p>So to facilitate the task, I want to call the above-mentionned login endpoint inside the middleware <code>isPasswordCorrect</code>, to check the identity of the user before updating his data</p>