/utils/xhr
Export the default xhr method to mapp.utils{}.
- Source
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:
PropertiesName | Type | Description |
---|---|---|
params | Object | The object containing the parameters. |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
params.url | string | The request URL. | ||
params.method | string | <optional> | GET | The request method. |
params.responseType | string | <optional> | json | The XHR responseType. |
params.requestHeader | Object | <optional> | {'Content-Type': 'application/json'} | The XHR requestHeader. |
params.body | string | <optional> | A stringified request body for a 'POST' request. | |
params.resolveTarget | boolean | <optional> | Whether the target instead of target.response should be resolved. | |
params.cache | boolean | <optional> | Whether the response should be cached in a Map(). |
- Source
Returns:
A promise that resolves with the XHR.
- Type:
- Promise