directual-api
v1.4.0
Published
Directual API for JavaScript
Downloads
23
Readme
directual-js-api
The Directual Web Library serves as the base JavaScript library for Directual based projects.
https://directual.com/
Support
- Explorer 11
- Chrome 43+
- Node 8.9+
Install
npm install directual-api
Usage in Node
const directual = require('directual-api');
const config = {
appID: '...',
//apiHost: 'http://localhost:8081'
}
const api = new Directual.default(config)
//example auth user
api.auth.login("test", "test").then((res)=>{
console.log("sessionID" + res.sessionID)
})
//example read data from API-endpoint with name `test` from structure UsageHistory
api
.structure('UsageHistory')
.getData('test', {sessionID:"", page:0})
.then((response) => {
console.dir(response, { depth: null })
})
.catch((e) => {
if(e.response.status === 403){
//todo: api endpoint required authorisation
}
if(e.response.status === 400){
//todo: api endpoint not found
}
})
//example for write data {id:1} to Api-endpoint with name `test` from structure UsageHistory
api
.structure('UsageHistory')
.setData('test', { id: 1 }, {sessionID:""})
.then((response) => {
console.dir(response, { depth: null })
})
.catch((e) => {
if (e.response.status === 403) {
//todo: api endpoint required authorisation
}
if (e.response.status === 400) {
//todo: api endpoint not found
}
})