title: Passing variables to the next middleware using next() in Express.js
body: <p>I want to pass some variable from the first middleware to another middleware, and I tried doing this, but there was &quot;<code>req.somevariable</code> is a given as 'undefined'&quot;.</p>
  <hr />
  <pre><code>//app.js
  ..
  app.get('/someurl/', middleware1, middleware2)
  ...
  </code></pre>
  <hr />
  <pre><code>////middleware1
  ...
  some conditions
  ...
  res.somevariable = variable1;
  next();
  ...
  </code></pre>
  <hr />
  <pre><code>////middleware2
  ...
  some conditions
  ...
  variable = req.somevariable;
  ...
  </code></pre>