Glen Swift Glen Swift - 9 months ago 108
Node.js Question

restify's body parser is not working for some reason

I don't understand why this works:


but this doesn't work:

instance.use((req, res, next) => {

Answer Source

use expects an argument of the form function (req, res, next). Therefore, when the first example works correctly, restify.bodyParser() is a function of this form. Hence, you will need pass req, res, next in the second example.

instance.use((req, res, next) => {
  restify.bodyParser()(req, res, next);