fetch
The Fetch function can be used to make HTTP request and to read resources that are part of the application.
When a relative URL is given, Tabris.js will interpret it as a path relative to the application’s main package.json
. This allows you to read static resources, i.e. the files residing in your project folder and not excluded via .tabrisignore
. You can also use URLs relative to the current module by using the __dirname
variable, e.g. fetch(__dirname + "/foo.txt");
.
To enable access to SSL protected resources that use self signed certificates add them to
app.trustedCertificates
. Alternatively you can disable theUseStrictSSL
preference in the config.xml to accept all certificates. See Building a Tabris.js App.
See also:
Class Request
Class Response
Class Headers
JSX fetch.jsx [► Run in Playground]
Methods
fetch(url, init?)
Parameter | Type | Description |
---|---|---|
url | string | Request |
|
init | object |
Optional. |
init.body | Blob |
The body of the request. GET or HEAD requests can not have a body. Optional. |
init.cache | string |
Optional. |
init.credentials | string |
Optional. |
init.headers | Headers |
The headers to add to the request. Optional. |
init.method | string |
The request method, e.g., 'GET' , 'POST' . Optional.
|
init.mode | string |
Optional. |
init.timeout | number |
The network request timeout in milliseconds Optional. |