Request

APINetworkingRequest

Source

Request.METHODS

Type:
Array

Contains available HTTP methods.

Contains:

Source

Request.TYPES

Type:
Array

Contains available expected types.

Contains:

Source

Request::constructor(options)

Parameters:
  • options — Object

Class used to describe coming networking request.

You should use createRequest() to create a full request.

Access it with:

var Networking = require('networking');
var Request = Networking.Request;

Source

Request::onLoadEnd(error, data)

Parameters:
  • error — Any
  • data — Any
Type:
Signal

Source

Request::uid

Type:
String
Read Only

Pseudo unique hash. It's created automatically.

Source

Request::pending

Type:
Boolean
Read Only

Indicates whether the request is not destroyed.

If it's false, the request can't be changed.

Source

Request::method

Type:
String

This property refers to one of the Request.METHODS values.

Holds a method with which the request has been called.

Source

Request::uri

Type:
Networking.Uri

Refers to the request URI path.

It can holds local and absolute paths.

// for request sent to the server ...
"http://server.domain/auth/user"

// for got request on the server ...
"http://server.domain/auth/user"

// for local requests ...
"/user/user_id"

Source

Request::type

Type:
String

Describes the expected response type.

It's used in the server-client communication. In most cases, a server returns a HTML document for a crawler, but client (which renders documents on his own side) expects a clean JSON response. That's why, these two requests have the same uri, but different expected types.

It refers to one of the Request.TYPES values.

Source

Request::data

Type:
Object
Default value:
null

Holds a data sent with a request. It can be, for instance, a form data.

Source

Request::handler

Type:
Networking.Handler
Read Only

Refers to the currently considered [Handler][networking/Handler].

Source

Request::response

Type:
Networking.Response
Read Only

Source

Request::params

Type:
Object
Default value:
{}
Read Only

Keeps matched parameters by the handler from the request uri.

Considering the /users/{name} URI, the 'name' property is available as the params.name.

Source

Request::headers

Type:
Object
Read Only

Contains request headers.

For the client request, this object is empty.

Source

Request::cookies

Type:
Object
Read Only

Source

Request::toString()

Returns:
String

Returns a string describing the request.

It contains a method, uri and a type.

console.log(req.toString);
// get /users/id as json

Source