Update index.md (#35322)

* Update index.md

Completion of the solution code.

* fix: changed code to json
This commit is contained in:
Harkirat Singh
2019-06-13 06:09:52 +05:30
committed by Christopher McCormack
parent 27bc7d81f2
commit 8f25305ab2

View File

@ -6,7 +6,7 @@ title: Use body-parser to Parse POST Requests
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds --> <!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
The body-parser should already be added to your project if you used the provided boilerplate, but if not it should be there as: The body-parser should already be added to your project if you used the provided boilerplate, but if not it should be there as:
```code ```json
"dependencies": { "dependencies": {
"body-parser": "^1.4.3", "body-parser": "^1.4.3",
... ...
@ -15,7 +15,9 @@ The body-parser should already be added to your project if you used the provided
All you need to do for this challenge is pass the middleware to app.use(). Make sure it comes before the paths it needs to be used on. Remember that body-parser returns with `bodyParser.urlencoded({extended: false})`. Use the following as a template: All you need to do for this challenge is pass the middleware to app.use(). Make sure it comes before the paths it needs to be used on. Remember that body-parser returns with `bodyParser.urlencoded({extended: false})`. Use the following as a template:
```javascript ```javascript
app.use(middleware-function); //app.use(middleware-function);
app.use(bodyParser.urlencoded({ extended: false }));
``` ```
<a href='https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/apis-and-microservices/basic-node-and-express/use-body-parser-to-parse-post-requests/index.md' target='_blank' rel='nofollow'>Help our community expand these hints and guides</a>. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/apis-and-microservices/basic-node-and-express/use-body-parser-to-parse-post-requests/index.md' target='_blank' rel='nofollow'>Help our community expand these hints and guides</a>.