title: How to resolve the problem TypeError: Router.use() requires middleware function but got a Object
body: <p>When I try to upload an image file on my server, I have this issue :</p>
  <blockquote>
  <p>TypeError: Router.use() requires middleware function but got a Object</p>
  </blockquote>
  <p>My form code :</p>
  <pre class="lang-html prettyprint-override"><code>    &lt;form action=&quot;/test.html&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot; name=&quot;monForm&quot;&gt;
        &lt;input type=&quot;file&quot; name=&quot;avatar&quot; /&gt;
        &lt;input type=&quot;submit&quot; value=&quot;Upload&quot;&gt;
      &lt;/form&gt;
  </code></pre>
  <p>My node code :</p>
  <pre class="lang-js prettyprint-override"><code>
      var express = require(&quot;express&quot;);
      var url = require(&quot;url&quot;);
      var router = express.Router();
      var bcrypt = require(&quot;bcryptjs&quot;);
      var path = require(&quot;path&quot;);
      var http = require(&quot;http&quot;);
      var mysql = require(&quot;mysql&quot;);
      var nodeMailer = require(&quot;nodemailer&quot;);
      var multer = require(&quot;multer&quot;);
      var upload = multer({ dest: &quot;uploads/&quot; });
      
      router.post(&quot;/test.html&quot;, upload.single(&quot;avatar&quot;), function (req, res, next) {
        //upload.single('avatar'),
        console.log(&quot;it's ok&quot;);
      
        res.render(&quot;test&quot;, {});
        // req.file is the `avatar` file
        // req.body will hold the text fields, if there were any
      });
      
      module.exports = router;
  </code></pre>
  <p>Thanks for your help !</p>