wilton/web/httpClient
HTTP client for web-browsers.
More...
Functions | |
Object | sendRequest (String url, Object options, Function|Undefined callback) |
Send XHR request to server. |
This module allows to use XHR requests in web-browsers with API similar to wilton/httpClient
Usage example:
Object web_httpClient::sendRequest | ( | String | url, |
Object | options, | ||
Function|Undefined | callback | ||
) |
Sends XHR request to server, calls callback on response received or on timeout.
url | String URL of the HTTP server |
options | Object configuration object, see possible options below |
callback | Function|Undefined callback to receive response or error, see response description below |
Object
XHR objectOptions
String|Object|Undefined
data to send in request body, specified object will be converted to JSONObject|Undefined
request metadataObject|Undefined
request headers in "Header-Name": "value"
formatString|Undefined
HTTP method to use for this request, default value is GET
, if request data
is not specified, POST
otherwiseBoolean|Undefined
whether to throw an Error
, if response status code >=400
is returned, default value: true
Number|Undefined
maximum time the request is allowed to take, in milliseconds, default value: 0
Response
String
data as a String
Function
parses the contents of data
field as a JSON, resulting JSON object is cached for this response instance - the same object is returned for the following json()
invocationsObject
response headers in "Header-Name": "value"
formatString
final URL (after possible redirection) that was usedNumber
HTTP response status code