Fetch module.
Methods
static checkStatus(response) → {Object}
Checks the response code. Returns the response object if it was successfull.
Otherwise it throws an error including the statusText
Parameters:
Name | Type | Description |
---|---|---|
response |
Object | A fetch response object with status and statusText as properties. |
the status text
String
the response object
Object
static json(u, optsopt) → {Promise.<any>}
Utility to fetch from url, check the responseStatus and parse response as JSON
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
u |
Object | the url | |
opts |
Object |
<optional> |
options used for querify and fetch |
the response body wrapped inside a Promise
Promise.<any>
static jsonP(u, optsopt) → {Promise.<any>}
Utility to fetch jsonp from url and check the responseStatus and parse response as JSON.
This method uses the fetch-jsonp library under the hood.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
u |
Object | the url | |
opts |
Object |
<optional> |
options used for querify and fetch |
the response body wrapped inside a Promise
Promise.<any>
static script(u) → {undefined}
Adds script tag with the passed url as source to the document.
Parameters:
Name | Type | Description |
---|---|---|
u |
Object | the url |
undefined
static text(u, optsopt) → {Promise.<String>}
Utility to fetch from url, check the responseStatus and parse response as text
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
u |
Object | the url | |
opts |
Object |
<optional> |
options used for querify and fetch |
the response body as text wrapped inside a Promise
Promise.<String>
static url(u, optsopt) → {Promise.<Response>}
Utility to fetch from url and check the responseStatus
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
u |
Object | the url | |
opts |
Object |
<optional> |
options used for querify and fetch |
the response object wrapped inside a Promise
Promise.<Response>
inner parseQueryParams(u, opts) → {string}
Appends query parameters as string to URL.
Parameters:
Name | Type | Description |
---|---|---|
u |
string | The url the query should be appended to |
opts |
Object | Object containing the queryParams and the stringifyOptions |
the new url string
string