directual-api
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i directual-api

Weekly Downloads

17

Version

1.4.0

License

MIT

Unpacked Size

60.7 kB

Total Files

27

Last publish

Collaborators

  • nikita_navalikhin