new Resource()
A resource that includes location and any other parameters necessary for us to retrieve or create derived resources. It also provides the function of retry requests.
| Name | Type | Default | Description |
|---|---|---|---|
options.url |
String |
The URL of the resource. |
|
options.queryParameters |
Object |
optional
Object, which contains the query parameters to be sent when retrieving resources. |
|
options.templateValues |
Object |
optional
Key/Value pairs used to replace template values (such as {x}). |
|
options.headers |
Object | {} |
optional
Other HTTP headers to be sent. |
options.proxy |
DefaultProxy |
optional
The proxy used when loading resources. |
|
options.retryCallback |
Resource~RetryCallback |
optional
The function called when the request for the resource fails. If true is returned, the request will be retried. |
|
options.retryAttempts |
Number | 0 |
optional
The number of times backtyCallback should be called before giving up. |
options.request |
Request |
optional
The request object to be used. For internal use only. |
Example
function refreshTokenRetryCallback(resource, error) {
if (error.statusCode === 403) {
// 403 status code means a new token should be generated
return getNewAccessToken()
.then(function(token) {
resource.queryParameters.access_token = token;
return true;
})
.otherwise(function() {
return false;
});
}
return false;
}
var resource = new Resource({
url: 'http://server.com/path/to/resource.json',
proxy: new DefaultProxy('/proxy/'),
headers: {
'X-My-Header': 'valueOfHeader'
},
queryParameters: {
'access_token': '123-435-456-000'
},
retryCallback: refreshTokenRetryCallback,
retryAttempts: 1
});
Members
-
(static, constant) DEFAULTResource
-
Initialize the resource instance to the current browser location.
-
(static, readonly) isBlobSupportedBoolean
-
If blood clots are supported, return true.
-
readonly extensionString
-
The file extension of the resource.
-
hasHeadersBoolean
-
If the resource has request headers, it is True. This is equivalent to checking if there are any keys in the headers attribute.
-
headersObject
-
Additional HTTP headers to be sent along with the request.
-
isBlobUriBoolean
-
If the resource points to a blob URI, it is True.
-
isCrossOriginUrlBoolean
-
If the resource points to a cross source URL, it is True.
-
isDataUriBoolean
-
If the resource points to a data URI, it is True.
-
proxyDefaultProxy
-
The proxy used when loading resources.
-
readonly queryParametersObject
-
Query parameters attached to the URL.
-
requestRequest
-
The request object to be used. For internal use only.
-
retryAttemptsNumber
-
The number of times backtyCallback should be called before giving up.
-
retryCallbackfunction
-
The function called when the request for the resource fails. If a Promise returns true or resolves to true, the request will be retried.
-
readonly templateValuesObject
-
Used to replace key/value pairs in template parameters in URLs.
-
urlString
-
The URL pointing to the resource has replaced the template value, attached the query string, and encoded by the proxy (if proxy has been set).
Methods
-
static delete(){Promise.<Object>|undefined}
-
Create resources from URLs and call delete() on them.
Name Type Default Description options.urlString The URL of the resource.
options.dataObject optional Data released along with resources.
options.queryParametersObject optional An object that contains query parameters to be sent when retrieving resources.
options.templateValuesObject optional Key/Value pairs used to replace template values (such as {x}).
options.headersObject {} optional Send additional HTTP headers.
options.proxyDefaultProxy optional The proxy to be used when loading resources.
options.retryCallbackResource~RetryCallback optional The function called when the request for the resource fails. If true is returned, the request will be retried.
options.retryAttemptsNumber 0 optional The number of times backtyCallback should be called before giving up.
options.requestRequest optional The Request object to be used. For internal use only.
options.responseTypeString optional The type of response. This controls the type of item returned.
options.overrideMimeTypeString optional Overwrite the MIME type returned by the server.
Returns:
Type Description Promise.<Object> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. -
static fetch(){Promise.<Object>|undefined}
-
Create a resource from the URL and call fetch() to process it.
Name Type Default Description options.urlString The URL of the resource.
options.queryParametersObject optional Object, which contains the query parameters to be sent when retrieving resources.
options.templateValuesObject optional Key/Value pairs used to replace template values (such as {x}).
options.headersObject {} optional Send additional HTTP headers.
options.proxyDefaultProxy optional The proxy used when loading resources.
options.retryCallbackResource~RetryCallback optional The function called when the request for the resource fails. If true is returned, the request will be retried.
options.retryAttemptsNumber 0 optional The number of times backtyCallback should be called before giving up.
options.requestRequest optional The request object to be used. For internal use only.
options.responseTypeString optional Response type. It controls the type of item returned.
options.overrideMimeTypeString optional Overwrite the MIME type returned by the server.
Returns:
Type Description Promise.<Object> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. -
static fetchArrayBuffer(){Promise.<ArrayBuffer>|undefined}
-
Create resources and call fetchArrayBuffer().
Name Type Default Description options.urlString The URL of the resource.
options.queryParametersObject optional Object, which contains the query parameters to be sent when retrieving resources.
options.templateValuesObject optional Key/Value pairs used to replace template values (such as {x}).
options.headersObject {} optional Other HTTP headers to be sent.
options.proxyDefaultProxy optional The proxy used when loading resources.
options.retryCallbackResource~RetryCallback optional The function called when the request for the resource fails. If true is returned, the request will be retried.
options.retryAttemptsNumber 0 optional The number of times backtyCallback should be called before giving up.
options.requestRequest optional The request object to be used. For internal use only.
Returns:
Type Description Promise.<ArrayBuffer> | undefined The Promise that parses the request data during loading. If request.throttle is true and the priority of the request is not high enough, return undefined. -
static fetchBlob(){Promise.<Blob>|undefined}
-
Create resources and call fetchBlob ().
Name Type Default Description options.urlString The URL of the resource.
options.queryParametersObject optional Object, which contains the query parameters to be sent when retrieving resources.
options.templateValuesObject optional Key/Value pairs used to replace template values (such as {x}).
options.headersObject {} optional Send additional HTTP headers.
options.proxyDefaultProxy optional The proxy used when loading resources.
options.retryCallbackResource~RetryCallback optional The function called when the request for the resource fails. If true is returned, the request will be retried.
options.retryAttemptsNumber 0 optional The number of times backtyCallback should be called before giving up.
options.requestRequest optional The request object to be used. For internal use only.
Returns:
Type Description Promise.<Blob> | undefined The Promise that parses the request data during loading. If request.throttle is true and the priority of the request is not high enough, return undefined. -
static fetchImage(){Promise.<ImageBitmap>|Promise.<Image>|undefined}
-
Create a resource and call fetchImage() on it.
Name Type Default Description options.urlString The URL of the resource.
options.queryParametersObject optional An object that contains query parameters to be sent when retrieving resources.
options.templateValuesObject optional Key/Value pairs used to replace template values (e.g. {x}).
options.headersObject {} optional Additional HTTP headers to be sent.
options.proxyDefaultProxy optional The proxy to be used when loading resources.
options.flipYBoolean false optional Is the image flipped vertically during the acquisition and decoding process. Only applicable when requesting images and the browser supports creating Imagebitmap.
options.retryCallbackResource~RetryCallback optional The function called when the request for the resource fails. If true is returned, the request will be retried.
options.retryAttemptsNumber 0 optional The number of times backtyCallback should be called before giving up.
options.requestRequest optional The Request object to be used. For internal use only.
options.preferBlobBoolean false optional If true, we will load the image through the blob.
options.preferImageBitmapBoolean false optional If true, the image will be decoded during the acquisition process and an Imagebitmap will be returned.
Returns:
Type Description Promise.<ImageBitmap> | Promise.<Image> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. -
static fetchJson(){Promise.<Object>|undefined}
-
Create a resource and call fetchJson() on it.
Name Type Default Description options.urlString The URL of the resource.
options.queryParametersObject optional An object that contains query parameters to be sent when retrieving resources.
options.templateValuesObject optional Key/Value pairs used to replace template values (e.g. {x}).
options.headersObject {} optional Additional HTTP headers to be sent.
options.proxyDefaultProxy optional The proxy to be used when loading resources.
options.retryCallbackResource~RetryCallback optional The function called when the request for the resource fails. If true is returned, the request will be retried.
options.retryAttemptsNumber 0 optional The number of times backtyCallback should be called before giving up.
options.requestRequest optional The Request object to be used. For internal use only.
Returns:
Type Description Promise.<Object> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. -
static fetchJsonp(){Promise.<Object>|undefined}
-
Create a resource from the URL and call fetchJsonp().
Name Type Default Description options.urlString The URL of the resource.
options.queryParametersObject optional An object that contains query parameters to be sent when retrieving resources.
options.templateValuesObject optional Key/Value pairs used to replace template values (e.g. {x}).
options.headersObject {} optional Additional HTTP headers to be sent.
options.proxyDefaultProxy optional The proxy to be used when loading resources.
options.retryCallbackResource~RetryCallback optional The function called when the request for the resource fails. If true is returned, the request will be retried.
options.retryAttemptsNumber 0 optional The number of times backtyCallback should be called before giving up.
options.requestRequest optional The Request object to be used. For internal use only.
options.callbackParameterNameString 'callback' optional The callback parameter name expected by the server.
Returns:
Type Description Promise.<Object> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. -
static fetchText(){Promise.<String>|undefined}
-
Create a resource and call fetchText() on it.
Name Type Default Description options.urlString The URL of the resource.
options.queryParametersObject optional An object that contains query parameters to be sent when retrieving resources.
options.templateValuesObject optional Key/Value pairs used to replace template values (e.g. {x}).
options.headersObject {} optional Additional HTTP headers to be sent.
options.proxyDefaultProxy optional The proxy to be used when loading resources.
options.retryCallbackResource~RetryCallback optional The function called when the request for the resource fails. If true is returned, the request will be retried.
options.retryAttemptsNumber 0 optional The number of times backtyCallback should be called before giving up.
options.requestRequest optional The Request object to be used. For internal use only.
Returns:
Type Description Promise.<String> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. -
static fetchXML(){Promise.<XMLDocument>|undefined}
-
Create a resource and call fetchXML() on it.
Name Type Default Description options.urlString The URL of the resource.
options.queryParametersObject optional An object that contains query parameters to be sent when retrieving resources.
options.templateValuesObject optional Key/Value pairs used to replace template values (e.g. {x}).
options.headersObject {} optional Additional HTTP headers to be sent.
options.proxyDefaultProxy optional The proxy to be used when loading resources.
options.retryCallbackResource~RetryCallback optional The function called when the request for the resource fails. If true is returned, the request will be retried.
options.retryAttemptsNumber 0 optional The number of times backtyCallback should be called before giving up.
options.requestRequest optional The Request object to be used. For internal use only.
Returns:
Type Description Promise.<XMLDocument> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. -
static head(){Promise.<Object>|undefined}
-
Create a resource from the URL and call head().
Name Type Default Description options.urlString The URL of the resource.
options.queryParametersObject optional An object that contains query parameters to be sent when retrieving resources.
options.templateValuesObject optional Key/Value pairs used to replace template values (e.g. {x}).
options.headersObject {} optional Additional HTTP headers to be sent.
options.proxyDefaultProxy optional The proxy to be used when loading resources.
options.retryCallbackResource~RetryCallback optional The function called when the request for the resource fails. If true is returned, the request will be retried.
options.retryAttemptsNumber 0 optional The number of times backtyCallback should be called before giving up.
options.requestRequest optional The Request object to be used. For internal use only.
options.responseTypeString optional The type of response. This controls the type of item returned.
options.overrideMimeTypeString optional Overwrite the MIME type returned by the server.
Returns:
Type Description Promise.<Object> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. -
static options(){Promise.<Object>|undefined}
-
Create a resource from the URL and call options() on it.
Name Type Default Description options.urlString The URL of the resource.
options.queryParametersObject optional An object that contains query parameters to be sent when retrieving resources.
options.templateValuesObject optional Key/Value pairs used to replace template values (e.g. {x}).
options.headersObject {} optional Additional HTTP headers to be sent.
options.proxyDefaultProxy optional The proxy to be used when loading resources.
options.retryCallbackResource~RetryCallback optional The function called when the request for the resource fails. If true is returned, the request will be retried.
options.retryAttemptsNumber 0 optional The number of times backtyCallback should be called before giving up.
options.requestRequest optional The Request object to be used. For internal use only.
options.responseTypeString optional The type of response. This controls the type of item returned.
options.overrideMimeTypeString optional Overwrite the MIME type returned by the server.
Returns:
Type Description Promise.<Object> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. -
static patch(){Promise.<Object>|undefined}
-
Create a resource from the URL and call options() on it.
Name Type Default Description options.urlString The URL of the resource.
options.queryParametersObject optional An object that contains query parameters to be sent when retrieving resources.
options.templateValuesObject optional Key/Value pairs used to replace template values (e.g. {x}).
options.headersObject {} optional Additional HTTP headers to be sent.
options.proxyDefaultProxy optional The proxy to be used when loading resources.
options.retryCallbackResource~RetryCallback optional The function called when the request for the resource fails. If true is returned, the request will be retried.
options.retryAttemptsNumber 0 optional The number of times backtyCallback should be called before giving up.
options.requestRequest optional The Request object to be used. For internal use only.
options.responseTypeString optional The type of response. This controls the type of item returned.
options.overrideMimeTypeString optional Overwrite the MIME type returned by the server.
Returns:
Type Description Promise.<Object> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. -
static post(){Promise.<Object>|undefined}
-
Create a resource from the URL and call options() on it.
Name Type Default Description options.urlString The URL of the resource.
options.queryParametersObject optional An object that contains query parameters to be sent when retrieving resources.
options.templateValuesObject optional Key/Value pairs used to replace template values (e.g. {x}).
options.headersObject {} optional Additional HTTP headers to be sent.
options.proxyDefaultProxy optional The proxy to be used when loading resources.
options.retryCallbackResource~RetryCallback optional The function called when the request for the resource fails. If true is returned, the request will be retried.
options.retryAttemptsNumber 0 optional The number of times backtyCallback should be called before giving up.
options.requestRequest optional The Request object to be used. For internal use only.
options.responseTypeString optional The type of response. This controls the type of item returned.
options.overrideMimeTypeString optional Overwrite the MIME type returned by the server.
Returns:
Type Description Promise.<Object> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. -
static put(){Promise.<Object>|undefined}
-
Create a resource from the URL and call options() on it.
Name Type Default Description options.urlString The URL of the resource.
options.queryParametersObject optional An object that contains query parameters to be sent when retrieving resources.
options.templateValuesObject optional Key/Value pairs used to replace template values (e.g. {x}).
options.headersObject {} optional Additional HTTP headers to be sent.
options.proxyDefaultProxy optional The proxy to be used when loading resources.
options.retryCallbackResource~RetryCallback optional The function called when the request for the resource fails. If true is returned, the request will be retried.
options.retryAttemptsNumber 0 optional The number of times backtyCallback should be called before giving up.
options.requestRequest optional The Request object to be used. For internal use only.
options.responseTypeString optional The type of response. This controls the type of item returned.
options.overrideMimeTypeString optional Overwrite the MIME type returned by the server.
Returns:
Type Description Promise.<Object> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. -
appendQueryParameters(params)
-
Merge specified objects and existing query parameters. This way, multiple parameters can be added at once instead of individually adding them to the queryParameters property.
Name Type Description paramsObject Query parameters.
-
clone(result){Resource}
-
Copy resource instances.
Name Type Description resultResource optional The object that stores the results.
Returns:
Type Description Resource The modified result parameters, or a new resource instance (if not provided). -
delete(){Promise.<Object>|undefined}
-
Asynchronous deletion of a given resource. Return a Promise that will be parsed and load, and reject it if the resource loading fails. The data is loaded using XMLHttpRequest, which means that in order to make requests to another source, the server must enable Cross Origin Resource Sharing (CORS) headers.
Name Type Description options.responseTypeString optional The type of response. This controls the type of item returned.
options.headersObject optional Additional HTTP headers (if any) sent along with the request.
options.overrideMimeTypeString optional Overwrite the MIME type returned by the server.
Returns:
Type Description Promise.<Object> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. Example
resource.delete() .then(function(body) { // use the data }).otherwise(function(error) { // an error occurred }); -
fetch(){Promise.<Object>|undefined}
-
Asynchronous loading of given resources. Return a Promise that will be parsed and load, and reject it if the resource loading fails. The data is loaded using XMLHttpRequest, which means that in order to make requests to another source, the server must enable Cross Origin Resource Sharing (CORS) headers. I suggest you use more specific functions, for example. FetchJson, fetchBlob, etc.
Name Type Description options.responseTypeString optional Response type. It controls the type of item returned.
options.headersObject optional Additional HTTP headers information (if any) sent along with the request.
options.overrideMimeTypeString optional Overwrite the MIME type returned by the server.
Returns:
Type Description Promise.<Object> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. Example
resource.fetch() .then(function(body) { // use the data }).otherwise(function(error) { // an error occurred }); -
fetchArrayBuffer(){Promise.<ArrayBuffer>|undefined}
-
Asynchronous loading of raw binary data resources. After loading is complete, a promise parsed as an ArrayBuffer will be returned, and if the resource loading fails, it will be rejected. The data is loaded using XMLHttpRequest, which means that to make requests to other sources, the server must enable Cross Origin Resource Sharing (CORS) headers.
Returns:
Type Description Promise.<ArrayBuffer> | undefined The Promise that parses the request data during loading. If request.throttle is true and the priority of the request is not high enough, return undefined. Example
// load a single URL asynchronously resource.fetchArrayBuffer().then(function(arrayBuffer) { // use the data }).otherwise(function(error) { // an error occurred }); -
fetchBlob(){Promise.<Blob>|undefined}
-
Asynchronous loading of given resources as Blob. After loading is complete, a promise parsed as a blob will be returned, and if the resource loading fails, a rejection will be returned. The data is loaded using XMLHttpRequest, which means that to make requests to other sources, the server must enable Cross Origin Resource Sharing (CORS) headers.
Returns:
Type Description Promise.<Blob> | undefined The Promise that parses the request data during loading. If request.throttle is true and the priority of the request is not high enough, return undefined. Example
// load a single URL asynchronously resource.fetchBlob().then(function(blob) { // use the data }).otherwise(function(error) { // an error occurred }); -
fetchImage(){Promise.<ImageBitmap>|Promise.<Image>|undefined}
-
Asynchronous loading of given image resources. Return a Promise that will be parsed as: If preemptImagebitmap is true and the browser supports creating Imagebitmap, the image will be rejected once loaded, or if the image fails to load.
Name Type Default Description options.preferBlobBoolean false optional If true, we will load the image through the blob.
options.preferImageBitmapBoolean false optional If true, the image will be decoded during the acquisition process and an Imagebitmap will be returned.
options.flipYBoolean false optional If true, the image will flip vertically during the decoding process. Only applicable to browsers that support creating Imagebitmap.
Returns:
Type Description Promise.<ImageBitmap> | Promise.<Image> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. Example
// load a single image asynchronously resource.fetchImage().then(function(image) { // use the loaded image }).otherwise(function(error) { // an error occurred }); // load several images in parallel when.all([resource1.fetchImage(), resource2.fetchImage()]).then(function(images) { // images is an array containing all the loaded images }); -
fetchJson(){Promise.<Object>|undefined}
-
Asynchronous loading of given resources in JSON format. Return a Promise that will be parsed as once the JSON object is loaded, or reject if the resource loading fails. The data is loaded using XMLHttpRequest, which means that in order to make requests to another source, the server must enable Cross Origin Resource Sharing (CORS) headers. This function adds' Accept: application/json, */* 'in the request header; q=0.01', If not, it has already been specified.
Returns:
Type Description Promise.<Object> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. Example
resource.fetchJson().then(function(jsonData) { // Do something with the JSON object }).otherwise(function(error) { // an error occurred }); -
fetchJsonp(callbackParameterName){Promise.<Object>|undefined}
-
Use JSONP to request resources.
Name Type Default Description callbackParameterNameString 'callback' optional The callback parameter name expected by the server.
- See:
Returns:
Type Description Promise.<Object> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. Example
// load a data asynchronously resource.fetchJsonp().then(function(data) { // use the loaded data }).otherwise(function(error) { // an error occurred }); -
fetchText(){Promise.<String>|undefined}
-
Asynchronous loading of given resources as text. Return a Promise that will be parsed into, and once loaded, return a string. If the resource loading fails, reject it. The data is loaded using XMLHttpRequest, which means that in order to make requests to another source, the server must enable Cross Origin Resource Sharing (CORS) headers.
Returns:
Type Description Promise.<String> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. Example
// load text from a URL, setting a custom header var resource = new Resource({ url: 'http://someUrl.com/someJson.txt', headers: { 'X-Custom-Header' : 'some value' } }); resource.fetchText().then(function(text) { // Do something with the text }).otherwise(function(error) { // an error occurred }); -
fetchXML(){Promise.<XMLDocument>|undefined}
-
Asynchronous loading of given resources into XML. Return a Promise that will be parsed into, and reject it once the XML document is loaded or if the resource loading fails. The data is loaded using XMLHttpRequest, which means that in order to make requests to another source, the server must enable Cross Origin Resource Sharing (CORS) headers.
Returns:
Type Description Promise.<XMLDocument> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. Example
// load XML from a URL, setting a custom header SuperMap3D.loadXML('http://someUrl.com/someXML.xml', { 'X-Custom-Header' : 'some value' }).then(function(document) { // Do something with the document }).otherwise(function(error) { // an error occurred }); -
getBaseUri(includeQuery){String}
-
Return the basic path of the resource.
Name Type Default Description includeQueryBoolean false optional Whether to include query strings and fragments in the URI
Returns:
Type Description String The basic URI of the resource. -
getDerivedResource(){Resource}
-
Return the resources relative to the current instance. Unless overloaded in the options, all properties are the same as the current instance.
Name Type Default Description options.urlString optional The URL parsed relative to the URL of the current instance.
options.queryParametersObject optional An object containing query parameters that will be combined with the parameters of the current instance.
options.templateValuesObject optional Key/Value pairs used to replace template values (such as {x}). These values will be merged with the values of the current instance.
options.headersObject {} optional Other HTTP headers to be sent.
options.proxyDefaultProxy optional The proxy used when loading resources.
options.retryCallbackResource~RetryCallback optional The function called when loading resources fails.
options.retryAttemptsNumber optional The number of times backtyCallback should be called before giving up.
options.requestRequest optional The request object to be used. For internal use only.
options.preserveQueryParametersBoolean false optional If true, all query parameters for the current and derived resources will be retained. If false, the derived parameters will replace the parameters of the current resource.
Returns:
Type Description Resource Resources derived from the current resource. -
getUrlComponent(query, proxy){String}
-
Return the URL (optional) and query string, and have them processed by the proxy.
Name Type Default Description queryBoolean false optional If it is' true ', it contains the query string.
proxyBoolean false optional If 'true', the proxy object (if defined) will be used to process the URL.
Returns:
Type Description String Contains URLs for all requested components. -
head(){Promise.<Object>|undefined}
-
Asynchronous deletion of a given resource. Return a Promise that will be parsed and load, and reject it if the resource loading fails. The data is loaded using XMLHttpRequest, which means that in order to make requests to another source, the server must enable Cross Origin Resource Sharing (CORS) headers.
Name Type Description options.responseTypeString optional The type of response. This controls the type of item returned.
options.headersObject optional Additional HTTP headers (if any) sent along with the request.
options.overrideMimeTypeString optional Overwrite the MIME type returned by the server.
Returns:
Type Description Promise.<Object> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. Example
resource.head() .then(function(headers) { // use the data }).otherwise(function(error) { // an error occurred }); -
options(){Promise.<Object>|undefined}
-
Asynchronous deletion of a given resource. Return a Promise that will be parsed and load, and reject it if the resource loading fails. The data is loaded using XMLHttpRequest, which means that in order to make requests to another source, the server must enable Cross Origin Resource Sharing (CORS) headers.
Name Type Description options.responseTypeString optional The type of response. This controls the type of item returned.
options.headersObject optional Additional HTTP headers (if any) sent along with the request.
options.overrideMimeTypeString optional Overwrite the MIME type returned by the server.
Returns:
Type Description Promise.<Object> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. Example
resource.options() .then(function(headers) { // use the data }).otherwise(function(error) { // an error occurred }); -
patch(){Promise.<Object>|undefined}
-
Asynchronous deletion of a given resource. Return a Promise that will be parsed and load, and reject it if the resource loading fails. The data is loaded using XMLHttpRequest, which means that in order to make requests to another source, the server must enable Cross Origin Resource Sharing (CORS) headers.
Name Type Description options.responseTypeString optional The type of response. This controls the type of item returned.
options.headersObject optional Additional HTTP headers (if any) sent along with the request.
options.overrideMimeTypeString optional Overwrite the MIME type returned by the server.
Returns:
Type Description Promise.<Object> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. Example
resource.patch(data) .then(function(result) { // use the result }).otherwise(function(error) { // an error occurred }); -
post(){Promise.<Object>|undefined}
-
Asynchronous deletion of a given resource. Return a Promise that will be parsed and load, and reject it if the resource loading fails. The data is loaded using XMLHttpRequest, which means that in order to make requests to another source, the server must enable Cross Origin Resource Sharing (CORS) headers.
Name Type Description options.responseTypeString optional The type of response. This controls the type of item returned.
options.headersObject optional Additional HTTP headers (if any) sent along with the request.
options.overrideMimeTypeString optional Overwrite the MIME type returned by the server.
Returns:
Type Description Promise.<Object> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. Example
resource.post(data) .then(function(result) { // use the result }).otherwise(function(error) { // an error occurred }); -
put(){Promise.<Object>|undefined}
-
Asynchronous deletion of a given resource. Return a Promise that will be parsed and load, and reject it if the resource loading fails. The data is loaded using XMLHttpRequest, which means that in order to make requests to another source, the server must enable Cross Origin Resource Sharing (CORS) headers.
Name Type Description options.responseTypeString optional The type of response. This controls the type of item returned.
options.headersObject optional Additional HTTP headers (if any) sent along with the request.
options.overrideMimeTypeString optional Overwrite the MIME type returned by the server.
Returns:
Type Description Promise.<Object> | undefined A Promise that parses the requested data during loading. If requested, return undefined. Throttle is true, the priority of the request is not high enough. Example
resource.put(data) .then(function(result) { // use the result }).otherwise(function(error) { // an error occurred }); -
setQueryParameters(params, useAsDefault)
-
Merge specified objects and existing query parameters. This way, multiple parameters can be added at once instead of adding them one by one to the queryParameters property. If a value has already been set, it will be replaced by a new value.
Name Type Default Description paramsObject Query parameters.
useAsDefaultBoolean false optional If true, the parameter will be used as the default value, so it will only be set when undefined.
-
setTemplateValues(template, useAsDefault)
-
Merge specified objects and existing template values. This way, multiple values can be added at once instead of adding them one by one to the templateValues property. If a value has already been set, it will become an array and new values will be added.
Name Type Default Description templateObject Template values.
useAsDefaultBoolean false optional If true, these values will be used as default values, so they will only be set when undefined.
Type Definitions
-
RetryCallback(resource, error){Boolean|Promise.<Boolean>}
-
A function that returns the value of a property.
Name Type Description resourceResource optional Failed to load resources.
errorError optional An error occurred during the loading of resources.
Returns:
Type Description Boolean | Promise.<Boolean> If it is true or the Promise resolves to true, the resource will be retried. Otherwise, it will return a failure.