-
staticCesium.Resource.delete(options) → Promise.<Object>|undefined
-
Creates a Resource from a URL and calls delete() on it.
Name |
Type |
Description |
options |
String
|
Object
|
A url or an object with the following properties
Name |
Type |
Default |
Description |
url |
String
|
|
The url of the resource. |
data |
Object
|
|
optional
Data that is posted with the resource. |
queryParameters |
Object
|
|
optional
An object containing query parameters that will be sent when retrieving the resource. |
templateValues |
Object
|
|
optional
Key/Value pairs that are used to replace template values (eg. {x}). |
headers |
Object
|
{}
|
optional
Additional HTTP headers that will be sent. |
proxy |
DefaultProxy
|
|
optional
A proxy to be used when loading the resource. |
retryCallback |
Resource~RetryCallback
|
|
optional
The Function to call when a request for this resource fails. If it returns true, the request will be retried. |
retryAttempts |
Number
|
0
|
optional
The number of times the retryCallback should be called before giving up. |
request |
Request
|
|
optional
A Request object that will be used. Intended for internal use only. |
responseType |
String
|
|
optional
The type of response. This controls the type of item returned. |
overrideMimeType |
String
|
|
optional
Overrides the MIME type returned by the server. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
-
staticCesium.Resource.fetch(options) → Promise.<Object>|undefined
-
Creates a Resource from a URL and calls fetch() on it.
Name |
Type |
Description |
options |
String
|
Object
|
A url or an object with the following properties
Name |
Type |
Default |
Description |
url |
String
|
|
The url of the resource. |
queryParameters |
Object
|
|
optional
An object containing query parameters that will be sent when retrieving the resource. |
templateValues |
Object
|
|
optional
Key/Value pairs that are used to replace template values (eg. {x}). |
headers |
Object
|
{}
|
optional
Additional HTTP headers that will be sent. |
proxy |
DefaultProxy
|
|
optional
A proxy to be used when loading the resource. |
retryCallback |
Resource~RetryCallback
|
|
optional
The Function to call when a request for this resource fails. If it returns true, the request will be retried. |
retryAttempts |
Number
|
0
|
optional
The number of times the retryCallback should be called before giving up. |
request |
Request
|
|
optional
A Request object that will be used. Intended for internal use only. |
responseType |
String
|
|
optional
The type of response. This controls the type of item returned. |
overrideMimeType |
String
|
|
optional
Overrides the MIME type returned by the server. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
-
staticCesium.Resource.fetchArrayBuffer(options) → Promise.<ArrayBuffer>|undefined
-
Creates a Resource and calls fetchArrayBuffer() on it.
Name |
Type |
Description |
options |
String
|
Object
|
A url or an object with the following properties
Name |
Type |
Default |
Description |
url |
String
|
|
The url of the resource. |
queryParameters |
Object
|
|
optional
An object containing query parameters that will be sent when retrieving the resource. |
templateValues |
Object
|
|
optional
Key/Value pairs that are used to replace template values (eg. {x}). |
headers |
Object
|
{}
|
optional
Additional HTTP headers that will be sent. |
proxy |
DefaultProxy
|
|
optional
A proxy to be used when loading the resource. |
retryCallback |
Resource~RetryCallback
|
|
optional
The Function to call when a request for this resource fails. If it returns true, the request will be retried. |
retryAttempts |
Number
|
0
|
optional
The number of times the retryCallback should be called before giving up. |
request |
Request
|
|
optional
A Request object that will be used. Intended for internal use only. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
-
staticCesium.Resource.fetchBlob(options) → Promise.<Blob>|undefined
-
Creates a Resource and calls fetchBlob() on it.
Name |
Type |
Description |
options |
String
|
Object
|
A url or an object with the following properties
Name |
Type |
Default |
Description |
url |
String
|
|
The url of the resource. |
queryParameters |
Object
|
|
optional
An object containing query parameters that will be sent when retrieving the resource. |
templateValues |
Object
|
|
optional
Key/Value pairs that are used to replace template values (eg. {x}). |
headers |
Object
|
{}
|
optional
Additional HTTP headers that will be sent. |
proxy |
DefaultProxy
|
|
optional
A proxy to be used when loading the resource. |
retryCallback |
Resource~RetryCallback
|
|
optional
The Function to call when a request for this resource fails. If it returns true, the request will be retried. |
retryAttempts |
Number
|
0
|
optional
The number of times the retryCallback should be called before giving up. |
request |
Request
|
|
optional
A Request object that will be used. Intended for internal use only. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
-
staticCesium.Resource.fetchImage(options) → Promise.<Image>|undefined
-
Creates a Resource and calls fetchImage() on it.
Name |
Type |
Description |
options |
String
|
Object
|
A url or an object with the following properties
Name |
Type |
Default |
Description |
url |
String
|
|
The url of the resource. |
queryParameters |
Object
|
|
optional
An object containing query parameters that will be sent when retrieving the resource. |
templateValues |
Object
|
|
optional
Key/Value pairs that are used to replace template values (eg. {x}). |
headers |
Object
|
{}
|
optional
Additional HTTP headers that will be sent. |
proxy |
DefaultProxy
|
|
optional
A proxy to be used when loading the resource. |
retryCallback |
Resource~RetryCallback
|
|
optional
The Function to call when a request for this resource fails. If it returns true, the request will be retried. |
retryAttempts |
Number
|
0
|
optional
The number of times the retryCallback should be called before giving up. |
request |
Request
|
|
optional
A Request object that will be used. Intended for internal use only. |
preferBlob |
Boolean
|
false
|
optional
If true, we will load the image via a blob. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
-
staticCesium.Resource.fetchJson(options) → Promise.<Object>|undefined
-
Creates a Resource and calls fetchJson() on it.
Name |
Type |
Description |
options |
String
|
Object
|
A url or an object with the following properties
Name |
Type |
Default |
Description |
url |
String
|
|
The url of the resource. |
queryParameters |
Object
|
|
optional
An object containing query parameters that will be sent when retrieving the resource. |
templateValues |
Object
|
|
optional
Key/Value pairs that are used to replace template values (eg. {x}). |
headers |
Object
|
{}
|
optional
Additional HTTP headers that will be sent. |
proxy |
DefaultProxy
|
|
optional
A proxy to be used when loading the resource. |
retryCallback |
Resource~RetryCallback
|
|
optional
The Function to call when a request for this resource fails. If it returns true, the request will be retried. |
retryAttempts |
Number
|
0
|
optional
The number of times the retryCallback should be called before giving up. |
request |
Request
|
|
optional
A Request object that will be used. Intended for internal use only. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
-
staticCesium.Resource.fetchJsonp(options) → Promise.<Object>|undefined
-
Creates a Resource from a URL and calls fetchJsonp() on it.
Name |
Type |
Description |
options |
String
|
Object
|
A url or an object with the following properties
Name |
Type |
Default |
Description |
url |
String
|
|
The url of the resource. |
queryParameters |
Object
|
|
optional
An object containing query parameters that will be sent when retrieving the resource. |
templateValues |
Object
|
|
optional
Key/Value pairs that are used to replace template values (eg. {x}). |
headers |
Object
|
{}
|
optional
Additional HTTP headers that will be sent. |
proxy |
DefaultProxy
|
|
optional
A proxy to be used when loading the resource. |
retryCallback |
Resource~RetryCallback
|
|
optional
The Function to call when a request for this resource fails. If it returns true, the request will be retried. |
retryAttempts |
Number
|
0
|
optional
The number of times the retryCallback should be called before giving up. |
request |
Request
|
|
optional
A Request object that will be used. Intended for internal use only. |
callbackParameterName |
String
|
'callback'
|
optional
The callback parameter name that the server expects. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
-
staticCesium.Resource.fetchText(options) → Promise.<String>|undefined
-
Creates a Resource and calls fetchText() on it.
Name |
Type |
Description |
options |
String
|
Object
|
A url or an object with the following properties
Name |
Type |
Default |
Description |
url |
String
|
|
The url of the resource. |
queryParameters |
Object
|
|
optional
An object containing query parameters that will be sent when retrieving the resource. |
templateValues |
Object
|
|
optional
Key/Value pairs that are used to replace template values (eg. {x}). |
headers |
Object
|
{}
|
optional
Additional HTTP headers that will be sent. |
proxy |
DefaultProxy
|
|
optional
A proxy to be used when loading the resource. |
retryCallback |
Resource~RetryCallback
|
|
optional
The Function to call when a request for this resource fails. If it returns true, the request will be retried. |
retryAttempts |
Number
|
0
|
optional
The number of times the retryCallback should be called before giving up. |
request |
Request
|
|
optional
A Request object that will be used. Intended for internal use only. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
-
staticCesium.Resource.fetchXML(options) → Promise.<XMLDocument>|undefined
-
Creates a Resource and calls fetchXML() on it.
Name |
Type |
Description |
options |
String
|
Object
|
A url or an object with the following properties
Name |
Type |
Default |
Description |
url |
String
|
|
The url of the resource. |
queryParameters |
Object
|
|
optional
An object containing query parameters that will be sent when retrieving the resource. |
templateValues |
Object
|
|
optional
Key/Value pairs that are used to replace template values (eg. {x}). |
headers |
Object
|
{}
|
optional
Additional HTTP headers that will be sent. |
proxy |
DefaultProxy
|
|
optional
A proxy to be used when loading the resource. |
retryCallback |
Resource~RetryCallback
|
|
optional
The Function to call when a request for this resource fails. If it returns true, the request will be retried. |
retryAttempts |
Number
|
0
|
optional
The number of times the retryCallback should be called before giving up. |
request |
Request
|
|
optional
A Request object that will be used. Intended for internal use only. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
-
staticCesium.Resource.head(options) → Promise.<Object>|undefined
-
Creates a Resource from a URL and calls head() on it.
Name |
Type |
Description |
options |
String
|
Object
|
A url or an object with the following properties
Name |
Type |
Default |
Description |
url |
String
|
|
The url of the resource. |
queryParameters |
Object
|
|
optional
An object containing query parameters that will be sent when retrieving the resource. |
templateValues |
Object
|
|
optional
Key/Value pairs that are used to replace template values (eg. {x}). |
headers |
Object
|
{}
|
optional
Additional HTTP headers that will be sent. |
proxy |
DefaultProxy
|
|
optional
A proxy to be used when loading the resource. |
retryCallback |
Resource~RetryCallback
|
|
optional
The Function to call when a request for this resource fails. If it returns true, the request will be retried. |
retryAttempts |
Number
|
0
|
optional
The number of times the retryCallback should be called before giving up. |
request |
Request
|
|
optional
A Request object that will be used. Intended for internal use only. |
responseType |
String
|
|
optional
The type of response. This controls the type of item returned. |
overrideMimeType |
String
|
|
optional
Overrides the MIME type returned by the server. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
-
staticCesium.Resource.options(options) → Promise.<Object>|undefined
-
Creates a Resource from a URL and calls options() on it.
Name |
Type |
Description |
options |
String
|
Object
|
A url or an object with the following properties
Name |
Type |
Default |
Description |
url |
String
|
|
The url of the resource. |
queryParameters |
Object
|
|
optional
An object containing query parameters that will be sent when retrieving the resource. |
templateValues |
Object
|
|
optional
Key/Value pairs that are used to replace template values (eg. {x}). |
headers |
Object
|
{}
|
optional
Additional HTTP headers that will be sent. |
proxy |
DefaultProxy
|
|
optional
A proxy to be used when loading the resource. |
retryCallback |
Resource~RetryCallback
|
|
optional
The Function to call when a request for this resource fails. If it returns true, the request will be retried. |
retryAttempts |
Number
|
0
|
optional
The number of times the retryCallback should be called before giving up. |
request |
Request
|
|
optional
A Request object that will be used. Intended for internal use only. |
responseType |
String
|
|
optional
The type of response. This controls the type of item returned. |
overrideMimeType |
String
|
|
optional
Overrides the MIME type returned by the server. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
-
staticCesium.Resource.patch(options) → Promise.<Object>|undefined
-
Creates a Resource from a URL and calls patch() on it.
Name |
Type |
Description |
options |
Object
|
A url or an object with the following properties
Name |
Type |
Default |
Description |
url |
String
|
|
The url of the resource. |
data |
Object
|
|
Data that is posted with the resource. |
queryParameters |
Object
|
|
optional
An object containing query parameters that will be sent when retrieving the resource. |
templateValues |
Object
|
|
optional
Key/Value pairs that are used to replace template values (eg. {x}). |
headers |
Object
|
{}
|
optional
Additional HTTP headers that will be sent. |
proxy |
DefaultProxy
|
|
optional
A proxy to be used when loading the resource. |
retryCallback |
Resource~RetryCallback
|
|
optional
The Function to call when a request for this resource fails. If it returns true, the request will be retried. |
retryAttempts |
Number
|
0
|
optional
The number of times the retryCallback should be called before giving up. |
request |
Request
|
|
optional
A Request object that will be used. Intended for internal use only. |
responseType |
String
|
|
optional
The type of response. This controls the type of item returned. |
overrideMimeType |
String
|
|
optional
Overrides the MIME type returned by the server. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
-
staticCesium.Resource.post(options) → Promise.<Object>|undefined
-
Creates a Resource from a URL and calls post() on it.
Name |
Type |
Description |
options |
Object
|
A url or an object with the following properties
Name |
Type |
Default |
Description |
url |
String
|
|
The url of the resource. |
data |
Object
|
|
Data that is posted with the resource. |
queryParameters |
Object
|
|
optional
An object containing query parameters that will be sent when retrieving the resource. |
templateValues |
Object
|
|
optional
Key/Value pairs that are used to replace template values (eg. {x}). |
headers |
Object
|
{}
|
optional
Additional HTTP headers that will be sent. |
proxy |
DefaultProxy
|
|
optional
A proxy to be used when loading the resource. |
retryCallback |
Resource~RetryCallback
|
|
optional
The Function to call when a request for this resource fails. If it returns true, the request will be retried. |
retryAttempts |
Number
|
0
|
optional
The number of times the retryCallback should be called before giving up. |
request |
Request
|
|
optional
A Request object that will be used. Intended for internal use only. |
responseType |
String
|
|
optional
The type of response. This controls the type of item returned. |
overrideMimeType |
String
|
|
optional
Overrides the MIME type returned by the server. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
-
staticCesium.Resource.put(options) → Promise.<Object>|undefined
-
Creates a Resource from a URL and calls put() on it.
Name |
Type |
Description |
options |
Object
|
A url or an object with the following properties
Name |
Type |
Default |
Description |
url |
String
|
|
The url of the resource. |
data |
Object
|
|
Data that is posted with the resource. |
queryParameters |
Object
|
|
optional
An object containing query parameters that will be sent when retrieving the resource. |
templateValues |
Object
|
|
optional
Key/Value pairs that are used to replace template values (eg. {x}). |
headers |
Object
|
{}
|
optional
Additional HTTP headers that will be sent. |
proxy |
DefaultProxy
|
|
optional
A proxy to be used when loading the resource. |
retryCallback |
Resource~RetryCallback
|
|
optional
The Function to call when a request for this resource fails. If it returns true, the request will be retried. |
retryAttempts |
Number
|
0
|
optional
The number of times the retryCallback should be called before giving up. |
request |
Request
|
|
optional
A Request object that will be used. Intended for internal use only. |
responseType |
String
|
|
optional
The type of response. This controls the type of item returned. |
overrideMimeType |
String
|
|
optional
Overrides the MIME type returned by the server. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
-
addQueryParameters(params, useAsDefault)
-
Combines the specified object and the existing query parameters. This allows you to add many parameters at once,
as opposed to adding them one at a time to the queryParameters property. If a value is already set, it will be replaced with the new value.
Name |
Type |
Default |
Description |
params |
Object
|
|
The query parameters |
useAsDefault |
Boolean
|
false
|
optional
If true the params will be used as the default values, so they will only be set if they are undefined. |
true
-
addTemplateValues(template, useAsDefault)
-
Combines the specified object and the existing template values. This allows you to add many values at once,
as opposed to adding them one at a time to the templateValues property. If a value is already set, it will become an array and the new value will be appended.
Name |
Type |
Default |
Description |
template |
Object
|
|
The template values |
useAsDefault |
Boolean
|
false
|
optional
If true the values will be used as the default values, so they will only be set if they are undefined. |
true
-
-
Appends a forward slash to the URL.
-
-
Combines the specified object and the existing query parameters. This allows you to add many parameters at once,
as opposed to adding them one at a time to the queryParameters property.
Name |
Type |
Description |
params |
Object
|
The query parameters |
-
-
Duplicates a Resource instance.
Name |
Type |
Description |
result |
Resource
|
optional
The object onto which to store the result. |
Returns:
The modified result parameter or a new Resource instance if one was not provided.
-
delete(options) → Promise.<Object>|undefined
-
Asynchronously deletes the given resource. Returns a promise that will resolve to
the result once loaded, or reject if the resource failed to load. The data is loaded
using XMLHttpRequest, which means that in order to make requests to another origin,
the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
Name |
Type |
Description |
options |
Object
|
optional
Object with the following properties:
Name |
Type |
Description |
responseType |
String
|
optional
The type of response. This controls the type of item returned. |
headers |
Object
|
optional
Additional HTTP headers to send with the request, if any. |
overrideMimeType |
String
|
optional
Overrides the MIME type returned by the server. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
Example:
resource.delete()
.then(function(body) {
// use the data
}).otherwise(function(error) {
// an error occurred
});
See:
-
fetch(options) → Promise.<Object>|undefined
-
Asynchronously loads the given resource. Returns a promise that will resolve to
the result once loaded, or reject if the resource failed to load. The data is loaded
using XMLHttpRequest, which means that in order to make requests to another origin,
the server must have Cross-Origin Resource Sharing (CORS) headers enabled. It's recommended that you use
the more specific functions eg. fetchJson, fetchBlob, etc.
Name |
Type |
Description |
options |
Object
|
optional
Object with the following properties:
Name |
Type |
Description |
responseType |
String
|
optional
The type of response. This controls the type of item returned. |
headers |
Object
|
optional
Additional HTTP headers to send with the request, if any. |
overrideMimeType |
String
|
optional
Overrides the MIME type returned by the server. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
Example:
resource.fetch()
.then(function(body) {
// use the data
}).otherwise(function(error) {
// an error occurred
});
See:
-
fetchArrayBuffer() → Promise.<ArrayBuffer>|undefined
-
Asynchronously loads the resource as raw binary data. Returns a promise that will resolve to
an ArrayBuffer once loaded, or reject if the resource failed to load. The data is loaded
using XMLHttpRequest, which means that in order to make requests to another origin,
the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
Example:
// load a single URL asynchronously
resource.fetchArrayBuffer().then(function(arrayBuffer) {
// use the data
}).otherwise(function(error) {
// an error occurred
});
See:
-
-
Asynchronously loads the given resource as a blob. Returns a promise that will resolve to
a Blob once loaded, or reject if the resource failed to load. The data is loaded
using XMLHttpRequest, which means that in order to make requests to another origin,
the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
Example:
// load a single URL asynchronously
resource.fetchBlob().then(function(blob) {
// use the data
}).otherwise(function(error) {
// an error occurred
});
See:
-
fetchImage(preferBlob) → Promise.<Image>|undefined
-
Asynchronously loads the given image resource. Returns a promise that will resolve to
an Image
once loaded, or reject if the image failed to load.
Name |
Type |
Default |
Description |
preferBlob |
Boolean
|
false
|
optional
If true, we will load the image via a blob. |
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
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
});
See:
-
-
Asynchronously loads the given resource as JSON. Returns a promise that will resolve to
a JSON object once loaded, or reject if the resource failed to load. The data is loaded
using XMLHttpRequest, which means that in order to make requests to another origin,
the server must have Cross-Origin Resource Sharing (CORS) headers enabled. This function
adds 'Accept: application/json,*/*;q=0.01' to the request headers, if not
already specified.
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
Example:
resource.fetchJson().then(function(jsonData) {
// Do something with the JSON object
}).otherwise(function(error) {
// an error occurred
});
See:
-
fetchJsonp(callbackParameterName) → Promise.<Object>|undefined
-
Requests a resource using JSONP.
Name |
Type |
Default |
Description |
callbackParameterName |
String
|
'callback'
|
optional
The callback parameter name that the server expects. |
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
Example:
// load a data asynchronously
resource.fetchJsonp().then(function(data) {
// use the loaded data
}).otherwise(function(error) {
// an error occurred
});
See:
-
fetchText() → Promise.<String>|undefined
-
Asynchronously loads the given resource as text. Returns a promise that will resolve to
a String once loaded, or reject if the resource failed to load. The data is loaded
using XMLHttpRequest, which means that in order to make requests to another origin,
the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
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
});
See:
-
fetchXML() → Promise.<XMLDocument>|undefined
-
Asynchronously loads the given resource as XML. Returns a promise that will resolve to
an XML Document once loaded, or reject if the resource failed to load. The data is loaded
using XMLHttpRequest, which means that in order to make requests to another origin,
the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
Example:
// load XML from a URL, setting a custom header
Cesium.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
});
See:
-
-
Returns the base path of the Resource.
Name |
Type |
Default |
Description |
includeQuery |
Boolean
|
false
|
optional
Whether or not to include the query string and fragment form the uri |
Returns:
The base URI of the resource
-
-
Returns a resource relative to the current instance. All properties remain the same as the current instance unless overridden in options.
Name |
Type |
Description |
options |
Object
|
An object with the following properties
Name |
Type |
Default |
Description |
url |
String
|
|
optional
The url that will be resolved relative to the url of the current instance. |
queryParameters |
Object
|
|
optional
An object containing query parameters that will be combined with those of the current instance. |
templateValues |
Object
|
|
optional
Key/Value pairs that are used to replace template values (eg. {x}). These will be combined with those of the current instance. |
headers |
Object
|
{}
|
optional
Additional HTTP headers that will be sent. |
proxy |
DefaultProxy
|
|
optional
A proxy to be used when loading the resource. |
retryCallback |
Resource~RetryCallback
|
|
optional
The function to call when loading the resource fails. |
retryAttempts |
Number
|
|
optional
The number of times the retryCallback should be called before giving up. |
request |
Request
|
|
optional
A Request object that will be used. Intended for internal use only. |
preserveQueryParameters |
Boolean
|
false
|
optional
If true, this will keep all query parameters from the current resource and derived resource. If false, derived parameters will replace those of the current resource. |
|
Returns:
The resource derived from the current one.
-
-
Returns the url, optional with the query string and processed by a proxy.
Name |
Type |
Default |
Description |
query |
Boolean
|
false
|
optional
If true, the query string is included. |
proxy |
Boolean
|
false
|
optional
If true, the url is processed the proxy object if defined. |
Returns:
The url with all the requested components.
-
head(options) → Promise.<Object>|undefined
-
Asynchronously gets headers the given resource. Returns a promise that will resolve to
the result once loaded, or reject if the resource failed to load. The data is loaded
using XMLHttpRequest, which means that in order to make requests to another origin,
the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
Name |
Type |
Description |
options |
Object
|
optional
Object with the following properties:
Name |
Type |
Description |
responseType |
String
|
optional
The type of response. This controls the type of item returned. |
headers |
Object
|
optional
Additional HTTP headers to send with the request, if any. |
overrideMimeType |
String
|
optional
Overrides the MIME type returned by the server. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
Example:
resource.head()
.then(function(headers) {
// use the data
}).otherwise(function(error) {
// an error occurred
});
See:
-
options(options) → Promise.<Object>|undefined
-
Asynchronously gets options the given resource. Returns a promise that will resolve to
the result once loaded, or reject if the resource failed to load. The data is loaded
using XMLHttpRequest, which means that in order to make requests to another origin,
the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
Name |
Type |
Description |
options |
Object
|
optional
Object with the following properties:
Name |
Type |
Description |
responseType |
String
|
optional
The type of response. This controls the type of item returned. |
headers |
Object
|
optional
Additional HTTP headers to send with the request, if any. |
overrideMimeType |
String
|
optional
Overrides the MIME type returned by the server. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
Example:
resource.options()
.then(function(headers) {
// use the data
}).otherwise(function(error) {
// an error occurred
});
See:
-
patch(data, options) → Promise.<Object>|undefined
-
Asynchronously patches data to the given resource. Returns a promise that will resolve to
the result once loaded, or reject if the resource failed to load. The data is loaded
using XMLHttpRequest, which means that in order to make requests to another origin,
the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
Name |
Type |
Description |
data |
Object
|
Data that is posted with the resource. |
options |
Object
|
optional
Object with the following properties:
Name |
Type |
Description |
responseType |
String
|
optional
The type of response. This controls the type of item returned. |
headers |
Object
|
optional
Additional HTTP headers to send with the request, if any. |
overrideMimeType |
String
|
optional
Overrides the MIME type returned by the server. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
Example:
resource.patch(data)
.then(function(result) {
// use the result
}).otherwise(function(error) {
// an error occurred
});
See:
-
post(data, options) → Promise.<Object>|undefined
-
Asynchronously posts data to the given resource. Returns a promise that will resolve to
the result once loaded, or reject if the resource failed to load. The data is loaded
using XMLHttpRequest, which means that in order to make requests to another origin,
the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
Name |
Type |
Description |
data |
Object
|
Data that is posted with the resource. |
options |
Object
|
optional
Object with the following properties:
Name |
Type |
Description |
data |
Object
|
optional
Data that is posted with the resource. |
responseType |
String
|
optional
The type of response. This controls the type of item returned. |
headers |
Object
|
optional
Additional HTTP headers to send with the request, if any. |
overrideMimeType |
String
|
optional
Overrides the MIME type returned by the server. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
Example:
resource.post(data)
.then(function(result) {
// use the result
}).otherwise(function(error) {
// an error occurred
});
See:
-
put(data, options) → Promise.<Object>|undefined
-
Asynchronously puts data to the given resource. Returns a promise that will resolve to
the result once loaded, or reject if the resource failed to load. The data is loaded
using XMLHttpRequest, which means that in order to make requests to another origin,
the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
Name |
Type |
Description |
data |
Object
|
Data that is posted with the resource. |
options |
Object
|
optional
Object with the following properties:
Name |
Type |
Description |
responseType |
String
|
optional
The type of response. This controls the type of item returned. |
headers |
Object
|
optional
Additional HTTP headers to send with the request, if any. |
overrideMimeType |
String
|
optional
Overrides the MIME type returned by the server. |
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle
is true and the request does not have high enough priority.
Example:
resource.put(data)
.then(function(result) {
// use the result
}).otherwise(function(error) {
// an error occurred
});
See:
-
setQueryParameters(params, useAsDefault)
-
Combines the specified object and the existing query parameters. This allows you to add many parameters at once,
as opposed to adding them one at a time to the queryParameters property. If a value is already set, it will be replaced with the new value.
Name |
Type |
Default |
Description |
params |
Object
|
|
The query parameters |
useAsDefault |
Boolean
|
false
|
optional
If true the params will be used as the default values, so they will only be set if they are undefined. |
-
setTemplateValues(template, useAsDefault)
-
Combines the specified object and the existing template values. This allows you to add many values at once,
as opposed to adding them one at a time to the templateValues property. If a value is already set, it will become an array and the new value will be appended.
Name |
Type |
Default |
Description |
template |
Object
|
|
The template values |
useAsDefault |
Boolean
|
false
|
optional
If true the values will be used as the default values, so they will only be set if they are undefined. |