npm.io
1.1.4 • Published 7 years ago

@webthatmatters/ybit-js-sdk

Licence
MIT
Version
1.1.4
Deps
0
Size
16 kB
Vulns
0
Weekly
0

yBit JS SDK

Installation

  npm install @webthatmatters/ybit-js-sdk 

Initialization

  import Ybit from '@webthatmatters/ybit-js-sdk';

  ...

  getToken = () => {
    const promise = new Promise(function(resolve, reject) {
      setTimeout(function() {
        resolve('INTEGRATION_TOKEN');
      }, 300);
    });

    return promise;
  };

  ...

  const yBit = new Ybit(this.getToken);

When in development pass your api URL and ui URL as a second param:

const yBit = new Ybit(this.getToken, {
  apiURL: 'http://localhost:3001',
  uiURL: 'http://localhost:3002'
})
Render Folders Tree

Create a container element

<div id="ybit-folders" />

and call the yBit foldersSelect function.

yBit.foldersSelect({ container: '#ybit-folders' }, data => {
  // This will be called every time a folder is selected
  console.log(data);
});