Skip to content

directual/directual-js-api

Repository files navigation

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
    }
  })

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published