About req.params, req.query, req.body other request object

Request object, is usually passed to the callback method, which means that you can name, usually named req or request.

The most common request object properties and methods:

req.params

An array containing the names of over routing parameters.

req.param(name)

Return route named parameters, POST or GET request or request parameters. I suggest you ignore this method.

req.query

An object containing key-value query string parameters stored (commonly referred to as GET request parameter).

req.body

An object containing POST request parameter. So named because REQUEST POST request body parameters passed, rather than transmitting the query string in the URL. To req.body available middleware required resolution request text content type.

req.route

Information about the current route of the match. The main route for debugging.

req.cookies/req.singnedCookies

An object that contains the value passed from the client cookies over.

req.headers

Received from the client request header.

req.accepts([types])

A simple method for determining whether to accept the type of a client or a set of designated (alternatively may be a single type of MIME type, such as application / json, a comma-separated set or an array). Write the public API of people are interested in this method. Assuming that the browser's default always accept HTML.

req.ip

IP address of the client.

req.path

Request path (not including protocol, host, port, or the query string).

req.host

A convenient way to return the host name of the client reported. This information can be forged, so it should not be used for security purposes.

req.xhr

A simple property that returns true if the request will be initiated by the Ajax.

req.protocol

A protocol (http or https) identification requests.

req.secure

A simple property, if the connection is secure, will return true. Equivalent to req.protocol === 'https'.

req.url/req.originalUrl

These properties return path and the query string (which does not include the protocol, the host or port) . req.url if for internal routing purposes, it can be rewritten, but req.orginalUrl

Designed to preserve the original request and query string.

req.acceptedLanguages

An easy way to return the client preferred a set of (human) language. This information is from the request header parsing come.

Guess you like

Origin www.cnblogs.com/angel648/p/11099260.html