Skip to content

Commit 0f12509

Browse files
authored
fix(docs): replace var with let or const in ReadMe (#581)
1 parent 5e6dd08 commit 0f12509

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ $ npm install body-parser
5151
## API
5252

5353
```js
54-
var bodyParser = require('body-parser')
54+
const bodyParser = require('body-parser')
5555
```
5656

5757
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.
404404
This is the simplest setup.
405405

406406
```js
407-
var express = require('express')
408-
var bodyParser = require('body-parser')
407+
const express = require('express')
408+
const bodyParser = require('body-parser')
409409

410-
var app = express()
410+
const app = express()
411411

412412
// parse application/x-www-form-urlencoded
413413
app.use(bodyParser.urlencoded())
@@ -429,16 +429,16 @@ need them. In general, this is the most recommended way to use body-parser with
429429
Express.
430430

431431
```js
432-
var express = require('express')
433-
var bodyParser = require('body-parser')
432+
const express = require('express')
433+
const bodyParser = require('body-parser')
434434

435-
var app = express()
435+
const app = express()
436436

437437
// create application/json parser
438-
var jsonParser = bodyParser.json()
438+
const jsonParser = bodyParser.json()
439439

440440
// create application/x-www-form-urlencoded parser
441-
var urlencodedParser = bodyParser.urlencoded()
441+
const urlencodedParser = bodyParser.urlencoded()
442442

443443
// POST /login gets urlencoded bodies
444444
app.post('/login', urlencodedParser, function (req, res) {
@@ -459,10 +459,10 @@ All the parsers accept a `type` option which allows you to change the
459459
`Content-Type` that the middleware will parse.
460460

461461
```js
462-
var express = require('express')
463-
var bodyParser = require('body-parser')
462+
const express = require('express')
463+
const bodyParser = require('body-parser')
464464

465-
var app = express()
465+
const app = express()
466466

467467
// parse various different custom JSON types as JSON
468468
app.use(bodyParser.json({ type: 'application/*+json' }))

0 commit comments

Comments
 (0)