Object that represents issued request for external data. Note it is "then'able", promise alike object that can be used with await
.
Constants
return values of Request.requestedDataType
property
- DATA_HTML
- - html document requested;
- DATA_IMAGE
- - image requested;
- DATA_STYLE
- - css requested;
- DATA_CURSOR
- - cursor requested;
- DATA_FONT
- - font data requested;
- DATA_RAW_DATA
- - any data requested,
view.request()
produces requests if this type.
Properties
- status
- - integer, response state - http response code: 200 - OK, 404 - not found, etc.
- requestDataType
- - integer, one DATA_*** values above, type of requested data.
- requestUrl
- - string, requested URL.
- response
- - string, value, stream or byte array - data requested. Particular type is depends on
output
parameter of view.request()
method.
- responseData
- - Bytes (byte array) - data requested as it was returned by server.
- responseMimeType
- - string, mime type of server response data.
- responseUrl
- - string, response URL ( can be different from requestUrl due to redirections ).
- isConsumed
- - boolean, true if the request is consumed (by destination element).
- isSucceeded
- - boolean, true if the request was completed with success.
- destination
- - Element or View object, that requested the data.
Methods
- fulfill
-
( data: Bytes , mime: string ) : this
Fulfill the request as if the data was delivered from server.
- reject
-
( status: integer ) : this
Reject the request as if server fails to deliver the data.
- then
-
( onSuccess: function [, onFailure: function] ) : this
Subscribes these functions to success and failure events on this request.
Where:
-
function onSuccess(data, status)
- receives response data and status code; function onFailure(err)
- receives failure as an instance of Error object.
Both functions are called with this set to the request object.
- catch
-
( callback: function ) : this
Subscribes the callback to failure event.
- finally
-
( callback: function ) : this
Subscribes the callback to completion event so the callback is called on either success or failure.