Skip to content

Commit

Permalink
Updated README as per ES6 conventions.
Browse files Browse the repository at this point in the history
Replaced var keyword with const, wherever applicable as per ES6 conventions
  • Loading branch information
Deveshb15 committed Feb 13, 2021
1 parent 480b1cf commit 94e474a
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ $ npm install body-parser
<!-- eslint-disable no-unused-vars -->

```js
var bodyParser = require('body-parser')
const bodyParser = require('body-parser')
```

The `bodyParser` object exposes various factories to create middlewares. All
Expand Down Expand Up @@ -376,10 +376,10 @@ top-level middleware, which will parse the bodies of all incoming requests.
This is the simplest setup.

```js
var express = require('express')
var bodyParser = require('body-parser')
const express = require('express')
const bodyParser = require('body-parser')

var app = express()
const app = express()

// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
Expand All @@ -401,16 +401,16 @@ need them. In general, this is the most recommended way to use body-parser with
Express.

```js
var express = require('express')
var bodyParser = require('body-parser')
const express = require('express')
const bodyParser = require('body-parser')

var app = express()
const app = express()

// create application/json parser
var jsonParser = bodyParser.json()
const jsonParser = bodyParser.json()

// create application/x-www-form-urlencoded parser
var urlencodedParser = bodyParser.urlencoded({ extended: false })
const urlencodedParser = bodyParser.urlencoded({ extended: false })

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

```js
var express = require('express')
var bodyParser = require('body-parser')
const express = require('express')
const bodyParser = require('body-parser')

var app = express()
const app = express()

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

0 comments on commit 94e474a

Please sign in to comment.