Constructor
# new RestAPI(readDefinitionopt, writeDefinitionopt)
The LocalStorage class encapsulates the access to data objects.
Name | Type | Attributes | Description |
---|---|---|---|
readDefinition |
Object |
<optional> |
An options object containing any custom settings that you want to apply to the read request. |
writeDefinition |
Object |
<optional> |
An options object containing any custom settings that you want to apply to the write request. |
- Since:
- 1.22.0
- Copyright:
- schukai GmbH
-
value is not a string
- Type
- TypeError
import {RestAPI} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.25.0/dist/modules/data/datasource/restapi.js';
const ds = new RestAPI({
url: 'https://httpbin.org/get'
},{
url: 'https://httpbin.org/post'
});
ds.set({flag:true})
ds.write().then(()=>console.log('done'));
ds.read().then(()=>console.log('done'));
Classes
- WriteError
the error is thrown by the rest api in case of error
Members
# defaults
Properties
Name | Type | Default | Description | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
url |
string | Defines the resource that you wish to fetch. |
|||||||||||||||||||||||||||||||||||||||||||||||||
write |
Object | {} | Options Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||
read.init |
Object | {} | An options object containing any custom settings that you want to apply to the request. The parameters are identical to those of the Request constructor Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||
read.acceptedStatus |
string | [200 | |||||||||||||||||||||||||||||||||||||||||||||||||
read.url |
string | URL |
|||||||||||||||||||||||||||||||||||||||||||||||||
read.mapping |
Object | the mapping is applied after reading. Properties
|
Methods
# getClone() → {RestAPI}
- Type
- RestAPI
# read() → {Promise}
-
-
the options does not contain a valid json definition
- Type
- Error
-
-
-
value is not a object
- Type
- TypeError
-
-
-
the data cannot be read
- Type
- Error
-
- Type
- Promise
# write() → {Promise}
-
the data cannot be written
- Type
- WriteError
- Type
- Promise