import JsonLoader from 'beloader/src/loaders/JsonLoader.js'
JsonLoader
Extends:
Load and parse JSON data
JsonLoader only performs asynchronously. If succeeded, returned data will be available in QueueItem#response property.
Example:
var loader = new Beloader();
loader
.fetch('json', 'https://reqres.in/api/users')
.then(function(item) {
var data = item.response; // JSON data
});
Test:
Constructor Summary
Public Constructor | ||
public |
constructor(parent: QueueItem, options: DotObjectArray) |
version 1.0.0 since 1.0.0 |
Method Summary
Public Methods | ||
public |
Async loader for JSON data |
version 1.0.0 since 1.0.0 |
public |
sync() Always throw an error because method is not allowed |
version 1.0.0 since 1.0.0 |
Private Methods | ||
private |
Event hook to add specific JSON request headers to XMLHttpRequest instance |
version 1.0.0 since 1.0.0 |
Public Constructors
public constructor(parent: QueueItem, options: DotObjectArray) version 1.0.0 since 1.0.0 source
Params:
Name | Type | Attribute | Description |
parent | QueueItem | QueueItem calling parent |
|
options | DotObjectArray | Options for loader |
Public Methods
public async(): Promise version 1.0.0 since 1.0.0 source
Async loader for JSON data
The loader will first try to fetch parsed JSON, then try to parse response itself and finally try to parse responseText for IE.
If none of parsing succeeds, promise is rejected.
public sync() version 1.0.0 since 1.0.0 source
Always throw an error because method is not allowed
Throw:
Always thrown if method requested |
Private Methods
private _loadstart() version 1.0.0 since 1.0.0 source
Event hook to add specific JSON request headers to XMLHttpRequest instance