Http
Http request object. Expose chainable API
Constructor Summary
Public Constructor | ||
public |
constructor(params: HttpRequestParams) |
Member Summary
Public Members | ||
public |
internals: * |
Method Summary
Public Methods | ||
public |
Adds body to request model |
|
public |
bodyProcessor(bodyProcessor: func): Object Sets the function which gets the body object as a parameter which result would be used as a request body |
|
public |
Executes HTTP request |
|
public |
executor(executor: function(url: string, method: string, headers: string[], responseType: string, body: Object): Promise): Object Set the middleware that will perform the request |
|
public |
Adds header to request model |
|
public |
Adds HTTP method information to request model |
|
public |
Adds query string param |
|
public |
responseProcessor(responseProcessor: func): Object Sets the function which gets the response and produces another value Useful for default HTTP error handling |
|
public |
responseType(responseType: string): Object Sets response content type Proper values could be obtained form XmlHttpRequest specification https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#Properties |
|
public |
Adds dynamic segment value |
|
public |
Adds URL information to HTTP request model |
Public Constructors
public constructor(params: HttpRequestParams) source
Params:
Name | Type | Attribute | Description |
params | HttpRequestParams | HTTP request params |
Public Members
public internals: * source
Public Methods
public body(body: Object): Object source
Adds body to request model
Params:
Name | Type | Attribute | Description |
body | Object | request payload |
public bodyProcessor(bodyProcessor: func): Object source
Sets the function which gets the body object as a parameter which result would be used as a request body
Params:
Name | Type | Attribute | Description |
bodyProcessor | func | f(x) => valid_http_body |
public executor(executor: function(url: string, method: string, headers: string[], responseType: string, body: Object): Promise): Object source
Set the middleware that will perform the request
public method(method: string): Object source
Adds HTTP method information to request model
Params:
Name | Type | Attribute | Description |
method | string | HTTP method |
public responseProcessor(responseProcessor: func): Object source
Sets the function which gets the response and produces another value Useful for default HTTP error handling
Params:
Name | Type | Attribute | Description |
responseProcessor | func | f(x) => y |
Example:
response => {
switch(response.code) {
case "404":
return { message: 'Resource not found' }
}
}
public responseType(responseType: string): Object source
Sets response content type Proper values could be obtained form XmlHttpRequest specification https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#Properties
Params:
Name | Type | Attribute | Description |
responseType | string | Proper values could be obtained form XmlHttpRequest specification https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#Properties |