The _ Namespace

.CONTENT_TYPE_HEADER {string}

The Content-Type HTTP header name.

The _.Error Class

Generic error that may occur during a request. … more

.FORM_CONTENT_TYPE {string}

The Content-Type HTTP header value for a url-encoded form.

The _.HttpError Class

Class for HTTP errors. … more

.Options

Configuration options for an XMLHttpRequest. - headers: map of header key/value pairs. - timeoutMs: number of milliseconds after which the request will be timed out by the client. Default is to allow the browser to handle timeouts. - withCredentials: whether user credentials are to be included in a cross-origin request. See: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/#the-withcredentials-attribute - mimeType: allows the caller to override the content-type and charset for the request, which is useful when requesting binary data. See: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/#dom-xmlhttprequest-overridemimetype - xssiPrefix: Prefix used for protecting against XSSI attacks, which should be removed before parsing the response as JSON.

@typedef
{{ headers: (Object.<string>|undefined), timeoutMs: (number|undefined), withCredentials: (boolean|undefined), mimeType: (string|undefined), xssiPrefix: (string|undefined) }}

.PostData

Defines the types that are allowed as post data.

@typedef
{(ArrayBuffer|Blob|Document|FormData|null|string|undefined)}

The _.TimeoutError Class

Class for Timeout errors. … more

.get(url, opt_options)

Sends a get request, returning a transformed result which will be resolved with the response text once the request completes.

url {string}
The URL to request.
opt_options {_.Options=}
Configuration options for the request.
returns {!Result}
A result object that will be resolved with the response text once the request finishes.

.getJson(url, opt_options)

Sends a get request, returning a result which will be resolved with the parsed response text once the request completes.

url {string}
The URL to request.
opt_options {_.Options=}
Configuration options for the request.
returns {!Result}
A result object that will be resolved with the response JSON once the request finishes.

.makeRequest(method, url, data, opt_options, opt_callback, opt_errback)

Creates a new XMLHttpRequest and initiates a request.

method {string}
The HTTP method for the request.
url {string}
The URL to request.
data {_.PostData}
The body of the post request, unless the content type is explicitly set in the Options, then it will default to form urlencoded.
opt_options {_.Options=}
Configuration options for the request.
opt_callback {function(XMLHttpRequest)=}
Optional callback to call when the request completes.
opt_errback {function(Error)=}
Optional callback to call when there is an error.
returns {!XMLHttpRequest}
The new XMLHttpRequest.

.post(url, data, opt_options)

Sends a post request, returning a transformed result which will be resolved with the response text once the request completes.

url {string}
The URL to request.
data {_.PostData}
The body of the post request.
opt_options {_.Options=}
Configuration options for the request.
returns {!Result}
A result object that will be resolved with the response text once the request finishes.

.postJson(url, data, opt_options)

Sends a post request, returning a result which will be resolved with the parsed response text once the request completes.

url {string}
The URL to request.
data {_.PostData}
The body of the post request.
opt_options {_.Options=}
Configuration options for the request.
returns {!Result}
A result object that will be resolved with the response JSON once the request finishes.

.send(method, url, data, opt_options)

Sends a request using XMLHttpRequest and returns a result.

method {string}
The HTTP method for the request.
url {string}
The URL to request.
data {_.PostData}
The body of the post request.
opt_options {_.Options=}
Configuration options for the request.
returns {!Result}
A result object that will be resolved with the XHR object as it's value when the request finishes.