Update index.md (#35323)
* Update index.md Completion of solution code. * Update guide/english/certifications/apis-and-microservices/basic-node-and-express/get-data-from-post-requests/index.md Co-Authored-By: Harkirat155 <harkirat.hira@gmail.com> * Update guide/english/certifications/apis-and-microservices/basic-node-and-express/get-data-from-post-requests/index.md Co-Authored-By: Harkirat155 <harkirat.hira@gmail.com>
This commit is contained in:
committed by
Randell Dawson
parent
ea3e5fff21
commit
e202b917d6
@ -10,12 +10,22 @@ Just like using req.query we can do req.body to get our data. This challenge is
|
||||
|
||||
In order to get data from a post request a general format is:
|
||||
|
||||
## Hint
|
||||
```javascript
|
||||
app.post(PATH, function(req, res) {
|
||||
// Handle the data in the request
|
||||
});
|
||||
```
|
||||
|
||||
## Solution
|
||||
```javascript
|
||||
app.post('/name', function(req, res) {
|
||||
// Handle the data in the request
|
||||
var string = req.body.first+ ' '+req.body.last;
|
||||
res.json({"name": string});
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
|
||||
<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>.
|
||||
|
Reference in New Issue
Block a user