@@ -51,7 +51,7 @@ $ npm install body-parser
51
51
## API
52
52
53
53
``` js
54
- var bodyParser = require (' body-parser' )
54
+ const bodyParser = require (' body-parser' )
55
55
```
56
56
57
57
The ` bodyParser ` object exposes various factories to create middlewares. All
@@ -404,10 +404,10 @@ top-level middleware, which will parse the bodies of all incoming requests.
404
404
This is the simplest setup.
405
405
406
406
``` js
407
- var express = require (' express' )
408
- var bodyParser = require (' body-parser' )
407
+ const express = require (' express' )
408
+ const bodyParser = require (' body-parser' )
409
409
410
- var app = express ()
410
+ const app = express ()
411
411
412
412
// parse application/x-www-form-urlencoded
413
413
app .use (bodyParser .urlencoded ())
@@ -429,16 +429,16 @@ need them. In general, this is the most recommended way to use body-parser with
429
429
Express.
430
430
431
431
``` js
432
- var express = require (' express' )
433
- var bodyParser = require (' body-parser' )
432
+ const express = require (' express' )
433
+ const bodyParser = require (' body-parser' )
434
434
435
- var app = express ()
435
+ const app = express ()
436
436
437
437
// create application/json parser
438
- var jsonParser = bodyParser .json ()
438
+ const jsonParser = bodyParser .json ()
439
439
440
440
// create application/x-www-form-urlencoded parser
441
- var urlencodedParser = bodyParser .urlencoded ()
441
+ const urlencodedParser = bodyParser .urlencoded ()
442
442
443
443
// POST /login gets urlencoded bodies
444
444
app .post (' /login' , urlencodedParser, function (req , res ) {
@@ -459,10 +459,10 @@ All the parsers accept a `type` option which allows you to change the
459
459
` Content-Type ` that the middleware will parse.
460
460
461
461
``` js
462
- var express = require (' express' )
463
- var bodyParser = require (' body-parser' )
462
+ const express = require (' express' )
463
+ const bodyParser = require (' body-parser' )
464
464
465
- var app = express ()
465
+ const app = express ()
466
466
467
467
// parse various different custom JSON types as JSON
468
468
app .use (bodyParser .json ({ type: ' application/*+json' }))
0 commit comments