/utils/xhr

Export the default xhr method to mapp.utils{}.

Methods

(inner) xhr(params) → {Promise}

The params object/string for the xhr utility method is required.

The params are assumed to the request URL if provided as a string argument.

The request params and response are stored in a Map() if the cache flag is set in the params object argument.

The method is assumed to be 'POST' if a params.body is provided.

Parameters:
NameTypeDescription
paramsObject

The object containing the parameters.

Properties
NameTypeAttributesDefaultDescription
params.urlstring

The request URL.

params.methodstring<optional>
GET

The request method.

params.responseTypestring<optional>
json

The XHR responseType.

params.requestHeaderObject<optional>
{'Content-Type': 'application/json'}

The XHR requestHeader.

params.bodystring<optional>

A stringified request body for a 'POST' request.

params.resolveTargetboolean<optional>

Whether the target instead of target.response should be resolved.

params.cacheboolean<optional>

Whether the response should be cached in a Map().

Returns:

A promise that resolves with the XHR.

Type: 
Promise