RequestInfo class

const requestInfo = new RequestInfo(data: ClientRequest, body: string | null);

constructor

The constructor of the RequestInfo class requires two arguments. The first argument must be an instance of the NodeJS built-in HTTP IncomingMessage class which provides the data of the request. The second argument must be a type of string or null and is the body which the client provided during the request.

Properties

url

The url where the request was made to by the client.

method

The method the client used (either GET or POST)

headers

An object with the headers which the client provided in the request where the key of the object the name of the header is and the value the value of the header.

query

An instance of the NodeJS built-in URLSearchParams class which provides the parameters provided by the client in the request.

body

When the request method is POST, a string with the provided body data of the client.

ip

A string which defines the IP address where the request was made from.

placeholders

An array with the values of the placeholders which have been set in the get or post EventEmitters of the HTTPServer class. The values are in the same order as the placeholders were set in the get or post EventEmitters.

Last updated