Methods
(inner) createFormData(object)
Creates a new FormData from an object
Parameters:
| Name | Type | Description |
|---|---|---|
object |
Object | URLSearchParams |
Returns:
FormData
(inner) fetchCSV(…args) → {Promise.<Object>}
Download a CSV file and parse it to an array of objects
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
args |
any |
<repeatable> |
same as |
Returns:
- Type
- Promise.<Object>
(inner) fetchDOM(…args) → {Promise.<HTMLDocument>}
Download an HTML file and parse it to HTMLDocument
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
args |
any |
<repeatable> |
same as |
Returns:
- Type
- Promise.<HTMLDocument>
(inner) fetchEx(resource, optionsopt)
Similar to fetch() but works different if body exists.
- if
bodyis a normal object (such as those created by{}), construct aURLSearchParamsfrom it. - if
bodyis anHTMLFormElement, construct aFormDatafrom it. - if
bodyis a normal object or aURLSearchParams, andmethodis set to 'GET' explicitly, convert the request into a URL with search param without, and then make the request without body. - if
bodyexists without settingmethod, warn and request with POST method.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
resource |
string | URL | Request | ||
options |
RequestInit |
<optional> |
(inner) fetchJSON(…args) → {Promise.<Object>}
Download a JSON file and deserialize it.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
args |
any |
<repeatable> |
same as |
Returns:
- Type
- Promise.<Object>
(inner) fetchStrict(args) → {Promise.<Response>}
Similar to fetchEx() but rejects if HTTP error (e.g "404 not found").
Parameters:
| Name | Type | Description |
|---|---|---|
args |
Array.<any> | same as |
Returns:
- Type
- Promise.<Response>
(inner) fetchText(…args) → {Promise.<string>}
Download a plain text file and read it.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
args |
any |
<repeatable> |
same as |
Returns:
- Type
- Promise.<string>
(inner) readFile(blob, type) → {Promise.<any>}
Promise version of FileReader.
Parameters:
| Name | Type | Description |
|---|---|---|
blob |
Blob | |
type |
string |
|
Returns:
- Type
- Promise.<any>