Home > Web Front-end > Front-end Q&A > What is the usage of req.body in node

What is the usage of req.body in node

WBOY
Release: 2022-04-22 15:58:41
Original
5043 people have browsed it

In node, "req.body" is used to obtain the data in the request; since parsing body is not provided by nodejs by default, this method needs to load the "body-parser" middleware before it can be used, and This method is usually used to parse the data of POST requests, and the syntax is "req.body.name".

What is the usage of req.body in node

The operating environment of this tutorial: windows10 system, nodejs version 12.19.0, Dell G3 computer.

What is the usage of req.body in node

Getting the parameters in the request is the only way for every web background processing. The express framework of nodejs provides four methods to achieve it. .

1,req.body

2,req.query

3,req.params

4,req.param()

req.body

A little translation: The key-value pair containing the submitted data is in the body of the request. The default is underfined.

You can use body- parser or multer to parse body

Parsing body is not provided by nodejs by default. You need to load the body-parser middleware before you can use req.body;

This method is usually used Parse the data in the POST request

req.body is used in the post request

The usage is as follows

What is the usage of req.body in node

Recommended learning: "nodejs video tutorial"

The above is the detailed content of What is the usage of req.body in node. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template