IO Class
Provides core IO-functionality.
Item Index
Methods
- _getClientId
- _getClientId
- _getClientId
- _initXHR
- _initXHR
- _initXHR
- _readyHandleXDR
- _readyHandleXDR
- _readyHandleXDR
- _setHeaders
- _setHeaders
- _setHeaders
- _setReadyHandle
- _setReadyHandle
- _setReadyHandle
- _setStreamHeader
- _setStreamHeader
- _setStreamHeader
- _toQueryString
- _toQueryString
- _toQueryString
- delete
- delete
- delete
- get
- get
- get
- getCSS
- getCSS
- getCSS
- getJS
- getJS
- getJS
- insert
- insert
- insert
- read
- read
- read
- readObjectJSONP
- readObjectJSONP
- readObjectJSONP
- readXML
- readXML
- readXML
- request
- request
- request
- send
- send
- send
- sendBlob
- sendBlob
- sendBlob
- update
- update
- update
Methods
_getClientId
-
url
Is send to the server and expects an unique id which can be used for its file-transactions.
Parameters:
-
urlStringURL of the resource server
Returns:
on success: Unique clientId on failure an Error object reason {Error}
_getClientId
-
url
Is send to the server and expects an unique id which can be used for its file-transactions.
Parameters:
-
urlStringURL of the resource server
Returns:
on success: Unique clientId on failure an Error object reason {Error}
_getClientId
-
url
Is send to the server and expects an unique id which can be used for its file-transactions.
Parameters:
-
urlStringURL of the resource server
Returns:
on success: Unique clientId on failure an Error object reason {Error}
_initXHR
-
xhr -
options -
fulfill -
reject -
promise
Initializes the xhr-instance, based on the config-params. This method is the standard way of doing xhr-requests without processing streams.
Parameters:
-
xhrObjectxhr-instance
-
optionsObject-
[url]String optionalThe url to which the request is sent.
-
[method='GET']String optionalThe HTTP method to use. can be ignored, even if streams are used --> the returned Promise will always hold all data
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true. This feature only works in the browser: nodejs will always perform asynchronous requests.
-
[data]Object optionalData to be sent to the server, either to be used by
query-paramsorbody. -
[headers]Object optionalHTTP request headers.
-
[responseType]String optionalForce the response type.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
-
fulfillFunctionreference to xhr-promise's fulfill-function
-
rejectFunctionreference to xhr-promise's reject-function
-
promisePromisethe xhr-promise which will be extended with the
abort()-method
_initXHR
-
xhr -
options -
fulfill -
reject -
promise
Initializes the xhr-instance, based on the config-params. This method is the standard way of doing xhr-requests without processing streams.
Parameters:
-
xhrObjectxhr-instance
-
optionsObject-
[url]String optionalThe url to which the request is sent.
-
[method='GET']String optionalThe HTTP method to use. can be ignored, even if streams are used --> the returned Promise will always hold all data
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true. This feature only works in the browser: nodejs will always perform asynchronous requests.
-
[data]Object optionalData to be sent to the server, either to be used by
query-paramsorbody. -
[headers]Object optionalHTTP request headers.
-
[responseType]String optionalForce the response type.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
-
fulfillFunctionreference to xhr-promise's fulfill-function
-
rejectFunctionreference to xhr-promise's reject-function
-
promisePromisethe xhr-promise which will be extended with the
abort()-method
_initXHR
-
xhr -
options -
fulfill -
reject -
promise
Initializes the xhr-instance, based on the config-params. This method is the standard way of doing xhr-requests without processing streams.
Parameters:
-
xhrObjectxhr-instance
-
optionsObject-
[url]String optionalThe url to which the request is sent.
-
[method='GET']String optionalThe HTTP method to use. can be ignored, even if streams are used --> the returned Promise will always hold all data
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true. This feature only works in the browser: nodejs will always perform asynchronous requests.
-
[data]Object optionalData to be sent to the server, either to be used by
query-paramsorbody. -
[headers]Object optionalHTTP request headers.
-
[responseType]String optionalForce the response type.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
-
fulfillFunctionreference to xhr-promise's fulfill-function
-
rejectFunctionreference to xhr-promise's reject-function
-
promisePromisethe xhr-promise which will be extended with the
abort()-method
_readyHandleXDR
-
xhr -
promise
Adds 2 methods on the xhr-instance which are used by xhr when events occur:
xhr.onload() xhr.onerror() // only XMLHttpRequest2
These events are only added in case of XDR
_readyHandleXDR
-
xhr -
promise
Adds 2 methods on the xhr-instance which are used by xhr when events occur:
xhr.onload() xhr.onerror() // only XMLHttpRequest2
These events are only added in case of XDR
_readyHandleXDR
-
xhr -
promise
Adds 2 methods on the xhr-instance which are used by xhr when events occur:
xhr.onload() xhr.onerror() // only XMLHttpRequest2
These events are only added in case of XDR
_setHeaders
-
xhr -
headers -
method
Adds the headers-object to xhr-headers.
_setHeaders
-
xhr -
headers -
method
Adds the headers-object to xhr-headers.
_setHeaders
-
xhr -
headers -
method
Adds the headers-object to xhr-headers.
_setReadyHandle
-
xhr -
fulfill -
reject
Adds 2 methods on the xhr-instance which are used by xhr when events occur:
xhr.onreadystatechange() xhr.ontimeout() // only XMLHttpRequest2
These events are responsible for making the Promise resolve.
_setReadyHandle
-
xhr -
fulfill -
reject
Adds 2 methods on the xhr-instance which are used by xhr when events occur:
xhr.onreadystatechange() xhr.ontimeout() // only XMLHttpRequest2
These events are responsible for making the Promise resolve.
_setReadyHandle
-
xhr -
fulfill -
reject
Adds 2 methods on the xhr-instance which are used by xhr when events occur:
xhr.onreadystatechange() xhr.ontimeout() // only XMLHttpRequest2
These events are responsible for making the Promise resolve.
_setStreamHeader
-
xhr -
headers -
method
Adds a headers X-Stream=true in case of a streaming request.
_setStreamHeader
-
xhr -
headers -
method
Adds a headers X-Stream=true in case of a streaming request.
_setStreamHeader
-
xhr -
headers -
method
Adds a headers X-Stream=true in case of a streaming request.
_toQueryString
-
data
Stringifies an object into one string with every pair separated by &
Parameters:
-
dataObjectcontaining key-value pairs
Returns:
stringified presentation of the object, with every pair separated by &
_toQueryString
-
data
Stringifies an object into one string with every pair separated by &
Parameters:
-
dataObjectcontaining key-value pairs
Returns:
stringified presentation of the object, with every pair separated by &
_toQueryString
-
data
Stringifies an object into one string with every pair separated by &
Parameters:
-
dataObjectcontaining key-value pairs
Returns:
stringified presentation of the object, with every pair separated by &
delete
-
url -
deleteKey -
[options]
Performs an AJAX DELETE request. Shortcut for a call to xhr with method set to 'DELETE'.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note: data should be a plain object with only primitive types which are transformed into key/value pairs.
Parameters:
-
urlStringURL of the resource server
-
deleteKeyObjectIndentification of the id that has to be deleted. Typically an object like: {id: 12} This object will be passed as the request params.
-
[options]Object optional-
[url]String optionalThe url to which the request is sent.
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[params]Object optionalData to be sent to the server.
-
[body]Object optionalThe content for the request body for POST method.
-
[headers]Object optionalHTTP request headers.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success:
response {Object|String} any response you want the server to return.
If the server send back a JSON-stringified object,
it will be parsed to return as a full object
You could set options.parseJSONDate true, it you want ISO8601-dates to be parsed as trully Date-objects
on failure an Error object
reason {Error}
delete
-
url -
deleteKey -
[options]
Performs an AJAX DELETE request. Shortcut for a call to xhr with method set to 'DELETE'.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note: data should be a plain object with only primitive types which are transformed into key/value pairs.
Parameters:
-
urlStringURL of the resource server
-
deleteKeyObjectIndentification of the id that has to be deleted. Typically an object like: {id: 12} This object will be passed as the request params.
-
[options]Object optional-
[url]String optionalThe url to which the request is sent.
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[params]Object optionalData to be sent to the server.
-
[body]Object optionalThe content for the request body for POST method.
-
[headers]Object optionalHTTP request headers.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success:
response {Object|String} any response you want the server to return.
If the server send back a JSON-stringified object,
it will be parsed to return as a full object
You could set options.parseJSONDate true, it you want ISO8601-dates to be parsed as trully Date-objects
on failure an Error object
reason {Error}
delete
-
url -
deleteKey -
[options]
Performs an AJAX DELETE request. Shortcut for a call to xhr with method set to 'DELETE'.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note: data should be a plain object with only primitive types which are transformed into key/value pairs.
Parameters:
-
urlStringURL of the resource server
-
deleteKeyObjectIndentification of the id that has to be deleted. Typically an object like: {id: 12} This object will be passed as the request params.
-
[options]Object optional-
[url]String optionalThe url to which the request is sent.
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[params]Object optionalData to be sent to the server.
-
[body]Object optionalThe content for the request body for POST method.
-
[headers]Object optionalHTTP request headers.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success:
response {Object|String} any response you want the server to return.
If the server send back a JSON-stringified object,
it will be parsed to return as a full object
You could set options.parseJSONDate true, it you want ISO8601-dates to be parsed as trully Date-objects
on failure an Error object
reason {Error}
get
-
url -
[params] -
[options]
Performs an AJAX GET request. Shortcut for a call to xhr with method set to 'GET'.
Additional parameters can be on the url (with questionmark), through params, or both.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note: params should be a plain object with only primitive types which are transformed into key/value pairs.
Parameters:
-
urlStringURL of the resource server
-
[params]Object optionaladditional parameters. should be a plain object with only primitive types which are transformed into key/value pairs.
-
[options]Object optional-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[headers]Object optionalHTTP request headers.
-
[responseType]String optionalForce the response type.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[preventCache=false]Boolean optionalwhether to prevent caching --> a timestamp is added by parameter _ts
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success: xhr {XMLHttpRequest|XDomainRequest} xhr-response on failure an Error object reason {Error}
get
-
url -
[params] -
[options]
Performs an AJAX GET request. Shortcut for a call to xhr with method set to 'GET'.
Additional parameters can be on the url (with questionmark), through params, or both.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note: params should be a plain object with only primitive types which are transformed into key/value pairs.
Parameters:
-
urlStringURL of the resource server
-
[params]Object optionaladditional parameters. should be a plain object with only primitive types which are transformed into key/value pairs.
-
[options]Object optional-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[headers]Object optionalHTTP request headers.
-
[responseType]String optionalForce the response type.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[preventCache=false]Boolean optionalwhether to prevent caching --> a timestamp is added by parameter _ts
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success: xhr {XMLHttpRequest|XDomainRequest} xhr-response on failure an Error object reason {Error}
get
-
url -
[params] -
[options]
Performs an AJAX GET request. Shortcut for a call to xhr with method set to 'GET'.
Additional parameters can be on the url (with questionmark), through params, or both.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note: params should be a plain object with only primitive types which are transformed into key/value pairs.
Parameters:
-
urlStringURL of the resource server
-
[params]Object optionaladditional parameters. should be a plain object with only primitive types which are transformed into key/value pairs.
-
[options]Object optional-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[headers]Object optionalHTTP request headers.
-
[responseType]String optionalForce the response type.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[preventCache=false]Boolean optionalwhether to prevent caching --> a timestamp is added by parameter _ts
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success: xhr {XMLHttpRequest|XDomainRequest} xhr-response on failure an Error object reason {Error}
getCSS
-
url -
[options]
Creates a <style> tag to load the CSS file at the given url.
Returns:
Promise holding the request. Has an additional .abort() method to cancel the request.
- on success: xhr {XMLHttpRequest1|XMLHttpRequest2} xhr-response
- on failure: reason {Error}
getCSS
-
url -
[options]
Creates a <style> tag to load the CSS file at the given url.
Returns:
Promise holding the request. Has an additional .abort() method to cancel the request.
- on success: xhr {XMLHttpRequest1|XMLHttpRequest2} xhr-response
- on failure: reason {Error}
getCSS
-
url -
[options]
Creates a <style> tag to load the CSS file at the given url.
Returns:
Promise holding the request. Has an additional .abort() method to cancel the request.
- on success: xhr {XMLHttpRequest1|XMLHttpRequest2} xhr-response
- on failure: reason {Error}
getJS
-
url -
[options]
Creates a <script> tag to load the script at the given url.
Returns:
Promise holding the request. Has an additional .abort() method to cancel the request.
- on success: xhr {XMLHttpRequest1|XMLHttpRequest2} xhr-response
- on failure: reason {Error}
getJS
-
url -
[options]
Creates a <script> tag to load the script at the given url.
Returns:
Promise holding the request. Has an additional .abort() method to cancel the request.
- on success: xhr {XMLHttpRequest1|XMLHttpRequest2} xhr-response
- on failure: reason {Error}
getJS
-
url -
[options]
Creates a <script> tag to load the script at the given url.
Returns:
Promise holding the request. Has an additional .abort() method to cancel the request.
- on success: xhr {XMLHttpRequest1|XMLHttpRequest2} xhr-response
- on failure: reason {Error}
insert
-
url -
data -
[options]
Performs an AJAX request with the POST HTTP method by default.
When options.allfields is true, it will use the PUT-method: see Note2.
The send data is an object which will be JSON-stringified before sending.
The 'content-type' of the header is set to 'application/json', overruling manually options.
'data' is send as 'body.data' and should be JSON-parsed at the server. 'body.action' has the value 'insert'
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note1: The server needs to inspect the bodyparam: 'action', which always equals 'insert'.
'body.action' is the way to distinquish 'I.IO.insertObject' from 'I.IO.updateObject'.
On purpose, we didn't make this distinction through a custom CONTENT-HEADER, because
that would lead into a more complicated CORS-setup (see Note3)
Note2: By default this method uses the POST-request: which is preferable if you don't know all the fields (like its unique id).
if you send ALL the fields, set options.allfields=true.
This will lead into using the PUT-method.
More about HTTP-methods: https://stormpath.com/blog/put-or-post/
Note3: CORS is supported, as long as the responseserver is set up to:
a) has a response header which allows the clientdomain:
header('Access-Control-Allow-Origin: http://www.some-site.com'); or header('Access-Control-Allow-Origin: *');
b) in cae you have set a custom HEADER (through 'options'), the responseserver MUST listen and respond
to requests with the OPTION-method
More info: allows to send to your domain: see http://remysharp.com/2011/04/21/getting-cors-working/
Note4: If the server response JSON-stringified data, the Promise resolves with a JS-Object. If you expect this object
to consist of Date-properties, you should set options.parseJSONDate true. Parsing takes a bit longer, but it will
generate trully Date-objects.
Parameters:
-
urlStringURL of the resource server
-
dataObject | PromiseData to be sent, might be a Promise which resolves with the data-object.
-
[options]Object optionalSee also:
I.io-
[allfields=false]Boolean optionalto specify that all the object-fields are sent.
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[headers]Object optionalHTTP request headers.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success: response {Object} usually, the final object-data, possibly modified, holding the key on failure an Error object reason {Error}
insert
-
url -
data -
[options]
Performs an AJAX request with the POST HTTP method by default.
When options.allfields is true, it will use the PUT-method: see Note2.
The send data is an object which will be JSON-stringified before sending.
The 'content-type' of the header is set to 'application/json', overruling manually options.
'data' is send as 'body.data' and should be JSON-parsed at the server. 'body.action' has the value 'insert'
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note1: The server needs to inspect the bodyparam: 'action', which always equals 'insert'.
'body.action' is the way to distinquish 'I.IO.insertObject' from 'I.IO.updateObject'.
On purpose, we didn't make this distinction through a custom CONTENT-HEADER, because
that would lead into a more complicated CORS-setup (see Note3)
Note2: By default this method uses the POST-request: which is preferable if you don't know all the fields (like its unique id).
if you send ALL the fields, set options.allfields=true.
This will lead into using the PUT-method.
More about HTTP-methods: https://stormpath.com/blog/put-or-post/
Note3: CORS is supported, as long as the responseserver is set up to:
a) has a response header which allows the clientdomain:
header('Access-Control-Allow-Origin: http://www.some-site.com'); or header('Access-Control-Allow-Origin: *');
b) in cae you have set a custom HEADER (through 'options'), the responseserver MUST listen and respond
to requests with the OPTION-method
More info: allows to send to your domain: see http://remysharp.com/2011/04/21/getting-cors-working/
Note4: If the server response JSON-stringified data, the Promise resolves with a JS-Object. If you expect this object
to consist of Date-properties, you should set options.parseJSONDate true. Parsing takes a bit longer, but it will
generate trully Date-objects.
Parameters:
-
urlStringURL of the resource server
-
dataObject | PromiseData to be sent, might be a Promise which resolves with the data-object.
-
[options]Object optionalSee also:
I.io-
[allfields=false]Boolean optionalto specify that all the object-fields are sent.
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[headers]Object optionalHTTP request headers.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success: response {Object} usually, the final object-data, possibly modified, holding the key on failure an Error object reason {Error}
insert
-
url -
data -
[options]
Performs an AJAX request with the POST HTTP method by default.
When options.allfields is true, it will use the PUT-method: see Note2.
The send data is an object which will be JSON-stringified before sending.
The 'content-type' of the header is set to 'application/json', overruling manually options.
'data' is send as 'body.data' and should be JSON-parsed at the server. 'body.action' has the value 'insert'
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note1: The server needs to inspect the bodyparam: 'action', which always equals 'insert'.
'body.action' is the way to distinquish 'I.IO.insertObject' from 'I.IO.updateObject'.
On purpose, we didn't make this distinction through a custom CONTENT-HEADER, because
that would lead into a more complicated CORS-setup (see Note3)
Note2: By default this method uses the POST-request: which is preferable if you don't know all the fields (like its unique id).
if you send ALL the fields, set options.allfields=true.
This will lead into using the PUT-method.
More about HTTP-methods: https://stormpath.com/blog/put-or-post/
Note3: CORS is supported, as long as the responseserver is set up to:
a) has a response header which allows the clientdomain:
header('Access-Control-Allow-Origin: http://www.some-site.com'); or header('Access-Control-Allow-Origin: *');
b) in cae you have set a custom HEADER (through 'options'), the responseserver MUST listen and respond
to requests with the OPTION-method
More info: allows to send to your domain: see http://remysharp.com/2011/04/21/getting-cors-working/
Note4: If the server response JSON-stringified data, the Promise resolves with a JS-Object. If you expect this object
to consist of Date-properties, you should set options.parseJSONDate true. Parsing takes a bit longer, but it will
generate trully Date-objects.
Parameters:
-
urlStringURL of the resource server
-
dataObject | PromiseData to be sent, might be a Promise which resolves with the data-object.
-
[options]Object optionalSee also:
I.io-
[allfields=false]Boolean optionalto specify that all the object-fields are sent.
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[headers]Object optionalHTTP request headers.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success: response {Object} usually, the final object-data, possibly modified, holding the key on failure an Error object reason {Error}
read
-
url -
[params] -
[options]
Performs an AJAX request with the GET HTTP method and expects a JSON-object. The resolved Promise-callback returns an object (JSON-parsed serverresponse).
Additional request-parameters can be on the url (with questionmark), through params, or both.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note1: If you expect the server to response with data that consist of Date-properties, you should set options.parseJSONDate true.
Parsing takes a bit longer, but it will generate trully Date-objects.
Note2: CORS is supported, as long as the responseserver is set up to:
a) has a response header which allows the clientdomain:
header('Access-Control-Allow-Origin: http://www.some-site.com'); or header('Access-Control-Allow-Origin: *');
b) in cae you have set a custom HEADER (through 'options'), the responseserver MUST listen and respond
to requests with the OPTION-method
More info: allows to send to your domain: see http://remysharp.com/2011/04/21/getting-cors-working/
Parameters:
-
urlStringURL of the resource server
-
[params]Object optionaladditional parameters.
-
[options]Object optionalSee also:
I.iocan be ignored, even if streams are used --> the returned Promise will always hold all data-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[headers]Object optionalHTTP request headers.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
[parseProto]Object optionalto set the prototype of any object.
-
[parseProtoCheck]Function optionalto determine in what case the specified
parseProtoshould be set as the prototype. The function accepts theobjectas argument and should return a trully value in order to set the prototype. When not specified,parseProtowill always be applied (ifparseProtois defined) -
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success: Object received data on failure an Error object reason {Error}
read
-
url -
[params] -
[options]
Performs an AJAX request with the GET HTTP method and expects a JSON-object. The resolved Promise-callback returns an object (JSON-parsed serverresponse).
Additional request-parameters can be on the url (with questionmark), through params, or both.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note1: If you expect the server to response with data that consist of Date-properties, you should set options.parseJSONDate true.
Parsing takes a bit longer, but it will generate trully Date-objects.
Note2: CORS is supported, as long as the responseserver is set up to:
a) has a response header which allows the clientdomain:
header('Access-Control-Allow-Origin: http://www.some-site.com'); or header('Access-Control-Allow-Origin: *');
b) in cae you have set a custom HEADER (through 'options'), the responseserver MUST listen and respond
to requests with the OPTION-method
More info: allows to send to your domain: see http://remysharp.com/2011/04/21/getting-cors-working/
Parameters:
-
urlStringURL of the resource server
-
[params]Object optionaladditional parameters.
-
[options]Object optionalSee also:
I.iocan be ignored, even if streams are used --> the returned Promise will always hold all data-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[headers]Object optionalHTTP request headers.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
[parseProto]Object optionalto set the prototype of any object.
-
[parseProtoCheck]Function optionalto determine in what case the specified
parseProtoshould be set as the prototype. The function accepts theobjectas argument and should return a trully value in order to set the prototype. When not specified,parseProtowill always be applied (ifparseProtois defined) -
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success: Object received data on failure an Error object reason {Error}
read
-
url -
[params] -
[options]
Performs an AJAX request with the GET HTTP method and expects a JSON-object. The resolved Promise-callback returns an object (JSON-parsed serverresponse).
Additional request-parameters can be on the url (with questionmark), through params, or both.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note1: If you expect the server to response with data that consist of Date-properties, you should set options.parseJSONDate true.
Parsing takes a bit longer, but it will generate trully Date-objects.
Note2: CORS is supported, as long as the responseserver is set up to:
a) has a response header which allows the clientdomain:
header('Access-Control-Allow-Origin: http://www.some-site.com'); or header('Access-Control-Allow-Origin: *');
b) in cae you have set a custom HEADER (through 'options'), the responseserver MUST listen and respond
to requests with the OPTION-method
More info: allows to send to your domain: see http://remysharp.com/2011/04/21/getting-cors-working/
Parameters:
-
urlStringURL of the resource server
-
[params]Object optionaladditional parameters.
-
[options]Object optionalSee also:
I.iocan be ignored, even if streams are used --> the returned Promise will always hold all data-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[headers]Object optionalHTTP request headers.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
[parseProto]Object optionalto set the prototype of any object.
-
[parseProtoCheck]Function optionalto determine in what case the specified
parseProtoshould be set as the prototype. The function accepts theobjectas argument and should return a trully value in order to set the prototype. When not specified,parseProtowill always be applied (ifparseProtois defined) -
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success: Object received data on failure an Error object reason {Error}
readObjectJSONP
-
url -
[options]
Creates a <style> tag to load the CSS file at the given url.
Returns:
Promise holding the request. Has an additional .abort() method to cancel the request.
- on success: xhr {XMLHttpRequest1|XMLHttpRequest2} xhr-response
- on failure: reason {Error}
readObjectJSONP
-
url -
[options]
Creates a <style> tag to load the CSS file at the given url.
Returns:
Promise holding the request. Has an additional .abort() method to cancel the request.
- on success: xhr {XMLHttpRequest1|XMLHttpRequest2} xhr-response
- on failure: reason {Error}
readObjectJSONP
-
url -
[options]
Creates a <style> tag to load the CSS file at the given url.
Returns:
Promise holding the request. Has an additional .abort() method to cancel the request.
- on success: xhr {XMLHttpRequest1|XMLHttpRequest2} xhr-response
- on failure: reason {Error}
readXML
-
url -
[params] -
[options]
Performs an AJAX request with the GET HTTP method and expects a JSON-object. The resolved Promise-callback returns an object (JSON-parsed serverresponse).
Additional request-parameters can be on the url (with questionmark), through params, or both.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note1: If you expect the server to response with data that consist of Date-properties, you should set options.parseJSONDate true.
Parsing takes a bit longer, but it will generate trully Date-objects.
Note2: CORS is supported, as long as the responseserver is set up to:
a) has a response header which allows the clientdomain:
header('Access-Control-Allow-Origin: http://www.some-site.com'); or header('Access-Control-Allow-Origin: *');
b) in cae you have set a custom HEADER (through 'options'), the responseserver MUST listen and respond
to requests with the OPTION-method
More info: allows to send to your domain: see http://remysharp.com/2011/04/21/getting-cors-working/
Parameters:
-
urlStringURL of the resource server
-
[params]Object optionaladditional parameters.
-
[options]Object optionalSee also:
I.io-
[url]String optionalThe url to which the request is sent. can be ignored, even if streams are used --> the returned Promise will always hold all data
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[params]Object optionalData to be sent to the server.
-
[body]Object optionalThe content for the request body for POST method.
-
[headers]Object optionalHTTP request headers.
-
[responseType='text']String optionalThe response type.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
Returns:
on success: Object received data on failure an Error object reason {Error}
readXML
-
url -
[params] -
[options]
Performs an AJAX request with the GET HTTP method and expects a JSON-object. The resolved Promise-callback returns an object (JSON-parsed serverresponse).
Additional request-parameters can be on the url (with questionmark), through params, or both.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note1: If you expect the server to response with data that consist of Date-properties, you should set options.parseJSONDate true.
Parsing takes a bit longer, but it will generate trully Date-objects.
Note2: CORS is supported, as long as the responseserver is set up to:
a) has a response header which allows the clientdomain:
header('Access-Control-Allow-Origin: http://www.some-site.com'); or header('Access-Control-Allow-Origin: *');
b) in cae you have set a custom HEADER (through 'options'), the responseserver MUST listen and respond
to requests with the OPTION-method
More info: allows to send to your domain: see http://remysharp.com/2011/04/21/getting-cors-working/
Parameters:
-
urlStringURL of the resource server
-
[params]Object optionaladditional parameters.
-
[options]Object optionalSee also:
I.io-
[url]String optionalThe url to which the request is sent. can be ignored, even if streams are used --> the returned Promise will always hold all data
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[params]Object optionalData to be sent to the server.
-
[body]Object optionalThe content for the request body for POST method.
-
[headers]Object optionalHTTP request headers.
-
[responseType='text']String optionalThe response type.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
Returns:
on success: Object received data on failure an Error object reason {Error}
readXML
-
url -
[params] -
[options]
Performs an AJAX request with the GET HTTP method and expects a JSON-object. The resolved Promise-callback returns an object (JSON-parsed serverresponse).
Additional request-parameters can be on the url (with questionmark), through params, or both.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note1: If you expect the server to response with data that consist of Date-properties, you should set options.parseJSONDate true.
Parsing takes a bit longer, but it will generate trully Date-objects.
Note2: CORS is supported, as long as the responseserver is set up to:
a) has a response header which allows the clientdomain:
header('Access-Control-Allow-Origin: http://www.some-site.com'); or header('Access-Control-Allow-Origin: *');
b) in cae you have set a custom HEADER (through 'options'), the responseserver MUST listen and respond
to requests with the OPTION-method
More info: allows to send to your domain: see http://remysharp.com/2011/04/21/getting-cors-working/
Parameters:
-
urlStringURL of the resource server
-
[params]Object optionaladditional parameters.
-
[options]Object optionalSee also:
I.io-
[url]String optionalThe url to which the request is sent. can be ignored, even if streams are used --> the returned Promise will always hold all data
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[params]Object optionalData to be sent to the server.
-
[body]Object optionalThe content for the request body for POST method.
-
[headers]Object optionalHTTP request headers.
-
[responseType='text']String optionalThe response type.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
Returns:
on success: Object received data on failure an Error object reason {Error}
request
-
options
Sends a HTTP request to the server and returns a Promise with an additional .abort() method to cancel the request. This method is the standard way of doing xhr-requests without processing streams.
Parameters:
-
optionsObject-
[url]String optionalThe url to which the request is sent.
-
[method='GET']String optionalThe HTTP method to use. can be ignored, even if streams are used --> the returned Promise will always hold all data
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[data]Object optionalData to be sent to the server, either to be used by
query-paramsorbody. -
[headers]Object optionalHTTP request headers.
-
[responseType]String optionalForce the response type.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[streamback]Function optionalcallbackfunction in case you want to process streams (needs io-stream module).
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
Promise holding the request. Has an additional .abort() method to cancel the request.
- on success: xhr {XMLHttpRequest1|XMLHttpRequest2} xhr-response
- on failure: reason {Error}
request
-
options
Sends a HTTP request to the server and returns a Promise with an additional .abort() method to cancel the request. This method is the standard way of doing xhr-requests without processing streams.
Parameters:
-
optionsObject-
[url]String optionalThe url to which the request is sent.
-
[method='GET']String optionalThe HTTP method to use. can be ignored, even if streams are used --> the returned Promise will always hold all data
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[data]Object optionalData to be sent to the server, either to be used by
query-paramsorbody. -
[headers]Object optionalHTTP request headers.
-
[responseType]String optionalForce the response type.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[streamback]Function optionalcallbackfunction in case you want to process streams (needs io-stream module).
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
Promise holding the request. Has an additional .abort() method to cancel the request.
- on success: xhr {XMLHttpRequest1|XMLHttpRequest2} xhr-response
- on failure: reason {Error}
request
-
options
Sends a HTTP request to the server and returns a Promise with an additional .abort() method to cancel the request. This method is the standard way of doing xhr-requests without processing streams.
Parameters:
-
optionsObject-
[url]String optionalThe url to which the request is sent.
-
[method='GET']String optionalThe HTTP method to use. can be ignored, even if streams are used --> the returned Promise will always hold all data
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[data]Object optionalData to be sent to the server, either to be used by
query-paramsorbody. -
[headers]Object optionalHTTP request headers.
-
[responseType]String optionalForce the response type.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[streamback]Function optionalcallbackfunction in case you want to process streams (needs io-stream module).
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
Promise holding the request. Has an additional .abort() method to cancel the request.
- on success: xhr {XMLHttpRequest1|XMLHttpRequest2} xhr-response
- on failure: reason {Error}
send
-
url -
data -
[options]
Performs an AJAX request with the PUT HTTP method by default.
When options.allfields is false, it will use the POST-method: see Note2.
The send data is an object which will be JSON-stringified before sending.
The 'content-type' of the header is set to 'application/json', overruling manually options.
'data' is send as 'body.data' and should be JSON-parsed at the server.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note1: By default this method uses the PUT-request: which is preferable is you send the WHOLE object.
if you send part of the fields, set options.allfields=false.
This will lead into using the POST-method.
More about HTTP-methods: https://stormpath.com/blog/put-or-post/
Note2: CORS is supported, as long as the responseserver is set up to:
a) has a response header which allows the clientdomain:
header('Access-Control-Allow-Origin: http://www.some-site.com'); or header('Access-Control-Allow-Origin: *');
b) in cae you have set a custom HEADER (through 'options'), the responseserver MUST listen and respond
to requests with the OPTION-method
More info: allows to send to your domain: see http://remysharp.com/2011/04/21/getting-cors-working/
Note3: If the server response JSON-stringified data, the Promise resolves with a JS-Object. If you expect this object
to consist of Date-properties, you should set options.parseJSONDate true. Parsing takes a bit longer, but it will
generate trully Date-objects.
Parameters:
-
urlStringURL of the resource server
-
dataObjectData to be sent.
-
[options]Object optionalSee also:
I.io-
[allfields=true]Boolean optionalto specify that all the object-fields are sent.
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[headers]Object optionalHTTP request headers.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success:
response {Object|String} any response you want the server to return.
If the server send back a JSON-stringified object,
it will be parsed to return as a full object
You could set options.parseJSONDate true, it you want ISO8601-dates to be parsed as trully Date-objects
on failure an Error object
reason {Error}
send
-
url -
data -
[options]
Performs an AJAX request with the PUT HTTP method by default.
When options.allfields is false, it will use the POST-method: see Note2.
The send data is an object which will be JSON-stringified before sending.
The 'content-type' of the header is set to 'application/json', overruling manually options.
'data' is send as 'body.data' and should be JSON-parsed at the server.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note1: By default this method uses the PUT-request: which is preferable is you send the WHOLE object.
if you send part of the fields, set options.allfields=false.
This will lead into using the POST-method.
More about HTTP-methods: https://stormpath.com/blog/put-or-post/
Note2: CORS is supported, as long as the responseserver is set up to:
a) has a response header which allows the clientdomain:
header('Access-Control-Allow-Origin: http://www.some-site.com'); or header('Access-Control-Allow-Origin: *');
b) in cae you have set a custom HEADER (through 'options'), the responseserver MUST listen and respond
to requests with the OPTION-method
More info: allows to send to your domain: see http://remysharp.com/2011/04/21/getting-cors-working/
Note3: If the server response JSON-stringified data, the Promise resolves with a JS-Object. If you expect this object
to consist of Date-properties, you should set options.parseJSONDate true. Parsing takes a bit longer, but it will
generate trully Date-objects.
Parameters:
-
urlStringURL of the resource server
-
dataObjectData to be sent.
-
[options]Object optionalSee also:
I.io-
[allfields=true]Boolean optionalto specify that all the object-fields are sent.
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[headers]Object optionalHTTP request headers.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success:
response {Object|String} any response you want the server to return.
If the server send back a JSON-stringified object,
it will be parsed to return as a full object
You could set options.parseJSONDate true, it you want ISO8601-dates to be parsed as trully Date-objects
on failure an Error object
reason {Error}
send
-
url -
data -
[options]
Performs an AJAX request with the PUT HTTP method by default.
When options.allfields is false, it will use the POST-method: see Note2.
The send data is an object which will be JSON-stringified before sending.
The 'content-type' of the header is set to 'application/json', overruling manually options.
'data' is send as 'body.data' and should be JSON-parsed at the server.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note1: By default this method uses the PUT-request: which is preferable is you send the WHOLE object.
if you send part of the fields, set options.allfields=false.
This will lead into using the POST-method.
More about HTTP-methods: https://stormpath.com/blog/put-or-post/
Note2: CORS is supported, as long as the responseserver is set up to:
a) has a response header which allows the clientdomain:
header('Access-Control-Allow-Origin: http://www.some-site.com'); or header('Access-Control-Allow-Origin: *');
b) in cae you have set a custom HEADER (through 'options'), the responseserver MUST listen and respond
to requests with the OPTION-method
More info: allows to send to your domain: see http://remysharp.com/2011/04/21/getting-cors-working/
Note3: If the server response JSON-stringified data, the Promise resolves with a JS-Object. If you expect this object
to consist of Date-properties, you should set options.parseJSONDate true. Parsing takes a bit longer, but it will
generate trully Date-objects.
Parameters:
-
urlStringURL of the resource server
-
dataObjectData to be sent.
-
[options]Object optionalSee also:
I.io-
[allfields=true]Boolean optionalto specify that all the object-fields are sent.
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[headers]Object optionalHTTP request headers.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success:
response {Object|String} any response you want the server to return.
If the server send back a JSON-stringified object,
it will be parsed to return as a full object
You could set options.parseJSONDate true, it you want ISO8601-dates to be parsed as trully Date-objects
on failure an Error object
reason {Error}
sendBlob
-
url -
blob -
[params] -
[options]
Sends a blob by using an AJAX PUT request.
Additional parameters can be through the params argument.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note: params should be a plain object with only primitive types which are transformed into key/value pairs.
Parameters:
-
urlStringURL of the resource server
-
blobBlobblob (data) representing the file to be send. Typically
HTMLInputElement.files[0] -
[params]Object optionaladditional parameters. NOTE: this object will be
stringifiedset a HEADER:x-dataon the request! should be a plain object with only primitive types which are transformed into key/value pairs. -
[options]Object optional-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[headers]Object optionalHTTP request headers.
-
[timeout=300000]Number optionalto timeout the request, leading into a rejected Promise. Defaults to 5 minutes
-
[progressfn]Function optionalcallbackfunction in case you want to process upload-status. Function has 3 parameters: total, loaded and target (io-promise)
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success: Object any received data on failure an Error object reason {Error}
sendBlob
-
url -
blob -
[params] -
[options]
Sends a blob by using an AJAX PUT request.
Additional parameters can be through the params argument.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note: params should be a plain object with only primitive types which are transformed into key/value pairs.
Parameters:
-
urlStringURL of the resource server
-
blobBlobblob (data) representing the file to be send. Typically
HTMLInputElement.files[0] -
[params]Object optionaladditional parameters. NOTE: this object will be
stringifiedset a HEADER:x-dataon the request! should be a plain object with only primitive types which are transformed into key/value pairs. -
[options]Object optional-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[headers]Object optionalHTTP request headers.
-
[timeout=300000]Number optionalto timeout the request, leading into a rejected Promise. Defaults to 5 minutes
-
[progressfn]Function optionalcallbackfunction in case you want to process upload-status. Function has 3 parameters: total, loaded and target (io-promise)
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success: Object any received data on failure an Error object reason {Error}
sendBlob
-
url -
blob -
[params] -
[options]
Sends a blob by using an AJAX PUT request.
Additional parameters can be through the params argument.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note: params should be a plain object with only primitive types which are transformed into key/value pairs.
Parameters:
-
urlStringURL of the resource server
-
blobBlobblob (data) representing the file to be send. Typically
HTMLInputElement.files[0] -
[params]Object optionaladditional parameters. NOTE: this object will be
stringifiedset a HEADER:x-dataon the request! should be a plain object with only primitive types which are transformed into key/value pairs. -
[options]Object optional-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[headers]Object optionalHTTP request headers.
-
[timeout=300000]Number optionalto timeout the request, leading into a rejected Promise. Defaults to 5 minutes
-
[progressfn]Function optionalcallbackfunction in case you want to process upload-status. Function has 3 parameters: total, loaded and target (io-promise)
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success: Object any received data on failure an Error object reason {Error}
update
-
url -
data -
[options]
Sends data (object) which will be JSON-stringified before sending.
Performs an AJAX request with the PUT HTTP method by default.
When options.allfields is false, it will use the POST-method: see Note2.
The 'content-type' of the header is set to 'application/json', overruling manually options.
'data' is send as 'body.data' and should be JSON-parsed at the server.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note1: The server needs to inspect the bodyparam: 'action', which always equals 'update'.
'body.action' is the way to distinquish 'I.IO.updateObject' from 'I.IO.insertObject'.
On purpose, we didn't make this distinction through a custom CONTENT-HEADER, because
that would lead into a more complicated CORS-setup (see Note3)
Note2: By default this method uses the PUT-request: which is preferable is you send the WHOLE object.
if you send part of the fields, set options.allfields=false.
This will lead into using the POST-method.
More about HTTP-methods: https://stormpath.com/blog/put-or-post/
Note3: CORS is supported, as long as the responseserver is set up to:
a) has a response header which allows the clientdomain:
header('Access-Control-Allow-Origin: http://www.some-site.com'); or header('Access-Control-Allow-Origin: *');
b) in cae you have set a custom HEADER (through 'options'), the responseserver MUST listen and respond
to requests with the OPTION-method
More info: allows to send to your domain: see http://remysharp.com/2011/04/21/getting-cors-working/
Note4: If the server response JSON-stringified data, the Promise resolves with a JS-Object. If you expect this object
to consist of Date-properties, you should set options.parseJSONDate true. Parsing takes a bit longer, but it will
generate trully Date-objects.
Parameters:
-
urlStringURL of the resource server
-
dataObject | PromiseData to be sent, might be a Promise which resolves with the data-object.
-
[options]Object optionalSee also:
I.io-
[allfields=true]Boolean optionalto specify that all the object-fields are sent.
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[headers]Object optionalHTTP request headers.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success: response {Object} usually, the final object-data, possibly modified on failure an Error object reason {Error}
update
-
url -
data -
[options]
Sends data (object) which will be JSON-stringified before sending.
Performs an AJAX request with the PUT HTTP method by default.
When options.allfields is false, it will use the POST-method: see Note2.
The 'content-type' of the header is set to 'application/json', overruling manually options.
'data' is send as 'body.data' and should be JSON-parsed at the server.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note1: The server needs to inspect the bodyparam: 'action', which always equals 'update'.
'body.action' is the way to distinquish 'I.IO.updateObject' from 'I.IO.insertObject'.
On purpose, we didn't make this distinction through a custom CONTENT-HEADER, because
that would lead into a more complicated CORS-setup (see Note3)
Note2: By default this method uses the PUT-request: which is preferable is you send the WHOLE object.
if you send part of the fields, set options.allfields=false.
This will lead into using the POST-method.
More about HTTP-methods: https://stormpath.com/blog/put-or-post/
Note3: CORS is supported, as long as the responseserver is set up to:
a) has a response header which allows the clientdomain:
header('Access-Control-Allow-Origin: http://www.some-site.com'); or header('Access-Control-Allow-Origin: *');
b) in cae you have set a custom HEADER (through 'options'), the responseserver MUST listen and respond
to requests with the OPTION-method
More info: allows to send to your domain: see http://remysharp.com/2011/04/21/getting-cors-working/
Note4: If the server response JSON-stringified data, the Promise resolves with a JS-Object. If you expect this object
to consist of Date-properties, you should set options.parseJSONDate true. Parsing takes a bit longer, but it will
generate trully Date-objects.
Parameters:
-
urlStringURL of the resource server
-
dataObject | PromiseData to be sent, might be a Promise which resolves with the data-object.
-
[options]Object optionalSee also:
I.io-
[allfields=true]Boolean optionalto specify that all the object-fields are sent.
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[headers]Object optionalHTTP request headers.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success: response {Object} usually, the final object-data, possibly modified on failure an Error object reason {Error}
update
-
url -
data -
[options]
Sends data (object) which will be JSON-stringified before sending.
Performs an AJAX request with the PUT HTTP method by default.
When options.allfields is false, it will use the POST-method: see Note2.
The 'content-type' of the header is set to 'application/json', overruling manually options.
'data' is send as 'body.data' and should be JSON-parsed at the server.
The Promise gets fulfilled if the server responses with STATUS-CODE in the 200-range (excluded 204).
It will be rejected if a timeout occurs (see options.timeout), or if xhr.abort() gets invoked.
Note1: The server needs to inspect the bodyparam: 'action', which always equals 'update'.
'body.action' is the way to distinquish 'I.IO.updateObject' from 'I.IO.insertObject'.
On purpose, we didn't make this distinction through a custom CONTENT-HEADER, because
that would lead into a more complicated CORS-setup (see Note3)
Note2: By default this method uses the PUT-request: which is preferable is you send the WHOLE object.
if you send part of the fields, set options.allfields=false.
This will lead into using the POST-method.
More about HTTP-methods: https://stormpath.com/blog/put-or-post/
Note3: CORS is supported, as long as the responseserver is set up to:
a) has a response header which allows the clientdomain:
header('Access-Control-Allow-Origin: http://www.some-site.com'); or header('Access-Control-Allow-Origin: *');
b) in cae you have set a custom HEADER (through 'options'), the responseserver MUST listen and respond
to requests with the OPTION-method
More info: allows to send to your domain: see http://remysharp.com/2011/04/21/getting-cors-working/
Note4: If the server response JSON-stringified data, the Promise resolves with a JS-Object. If you expect this object
to consist of Date-properties, you should set options.parseJSONDate true. Parsing takes a bit longer, but it will
generate trully Date-objects.
Parameters:
-
urlStringURL of the resource server
-
dataObject | PromiseData to be sent, might be a Promise which resolves with the data-object.
-
[options]Object optionalSee also:
I.io-
[allfields=true]Boolean optionalto specify that all the object-fields are sent.
-
[sync=false]Boolean optionalBy default, all requests are sent asynchronously. To send synchronous requests, set to true.
-
[headers]Object optionalHTTP request headers.
-
[timeout=3000]Number optionalto timeout the request, leading into a rejected Promise.
-
[withCredentials=false]Boolean optionalWhether or not to send credentials on the request.
-
[parseJSONDate=false]Boolean optionalWhether the server returns JSON-stringified data which has Date-objects.
-
[stayActive]Number optionalminimal time the request should be pending, even if IO has finished
-
Returns:
on success: response {Object} usually, the final object-data, possibly modified on failure an Error object reason {Error}
