Request

API ReferenceNetworkingRequest

Source


Request.METHODS

Static property of
Request
Type
Array

Contains available HTTP methods.

Contains:

  • Request.GET,
  • Request.POST,
  • Request.PUT,
  • Request.DELETE,
  • Request.OPTIONS.

Source


Request.TYPES

Static property of
Request
Type
Array

Contains available expected types.

Contains:

  • Request.TEXT_TYPE,
  • Request.JSON_TYPE,
  • Request.HTML_TYPE,
  • Request.BINARY_TYPE.

Source


constructor()

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


onLoadEnd()

Parameters
  • error — Any
  • data — Any
Type
Signal

Source


uid

Type
String
Read Only

Pseudo unique hash. It's created automatically.

Source


pending

Type
Boolean
Read Only

Indicates whether the request is not destroyed.

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

Source


method

Type
String

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

Holds a method with which the request has been called.

Source


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


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


data

Type
Object
Default
null

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

Source


handler

Type
Networking.Handler
Read Only

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

Source


response

Type
Networking.Response
Read Only

Source


params

Type
Object
Default
{}
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


headers

Type
Object
Read Only

Contains request headers.

For the client request, this object is empty.

Source


cookies

Type
Object
Read Only

Source


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

results matching ""

    No results matching ""