Skip to content

Request

Hugo Persson edited this page Dec 10, 2020 · 2 revisions

Request object


The request object is a property of the Controller base class and the object can be accessed by any class that extends Controller with:

this.req

The request object expose all information about the request from the user. The Request class extends the nodejs http.ServerListener

Properties

Query string

Query strings are parsed and stored in the property queryStrings

// for the path /Dashboard/doSomething?name=Hugo&age=18
console.log(this.req.queryStrings);
// Would output
{
    name:"Hugo",
    age:"18"
}

Params

Params are parsed by the pattern: /name/value/ meaning that if you would like to pass the id and name for a user you would use the following path /Dashboard/doSomething/name/Hugo/id/4.

// for the path /Dashboard/doSomething/name/Hugo/id/4 
console.log(this.req.params);
// Would output
{
    name:"Hugo",
    age:"18"
}

Cookies

A read only property returning the cookies sent to the user

Method

A readonly property returning the request type the user used to access the server. It returns en enum of ActionType.

Body

PyramidJS only supports JSON request but if you want to parse any other type of data use a middleware.

Clone this wiki locally