Home > Mobile >  nodejs require multiple files
nodejs require multiple files

Time:10-29

can some one explain, I am confused by the bodyparser library in nodeJS. There is this line

var deprecate = require('depd')('body-parser')

If I look for IDE definitions for deprecate, it points to the depd library, but I am not sure what the second (body-parser) parameter doing here?

CodePudding user response:

The line you ask about "activates" depd library for body-parser library. You can get more details here: https://www.npmjs.com/package/depd Anyway, if you use express, body-parser is embedded and you do not need to require it. For more details: https://expressjs.com/en/resources/middleware/body-parser.html

CodePudding user response:

All you're doing is calling a function twice. You need to use the "&&" operator to run seperate functions:

  var deprecate = require('depd') && require('body-parser')
  • Related