0.9.0 • Published 4 years ago

@panflux/sdk v0.9.0

Weekly downloads
13
License
MIT
Repository
github
Last release
4 years ago

Panflux Javascript SDK

Build Status Codecov npm version GitHub license

This is the Javascript client library (SDK) for consuming Panflux APIs.

Install

# Choose your flavor of package manager:
yarn add @panflux/sdk
# or
npm i --save @panflux/sdk

Usage

Load the client class:

const {Client} = require('@panflux/sdk');
// or
import Client from '@panflux/sdk';

Initialize the client:

const client = Client.init({
    clientID: 'your-id',
    clientSecret: 'your-secret',
    tokenURL: 'endpoint-if-not-default'
})

Do a simple query:

client.query('query { me { id, name } }')
    .then(({data, errors}) => {
        if (errors) {
            console.log(errors);
        }
        if (data) {
            console.info(`Authenticated as ${data.me.name}`);
        }
    });

Or with variables:

client.query('query result($id: UUID!) { user(id: $id) { id, name } }', {
    'id' => 'your-user-id',    
}).then(({data}) => {
    console.info(`Authenticated as ${data.result.name}`);
});

Subscribe to ping tests:

client.subscribe('subscription { ping }',
    data => console.info(data),
    err => console.error(err),
    () => console.info('Subscription closed'),
})
    .then(subscription => {
        setTimeout(() => subscription.unsubscribe(), 5000);
    });

License

MIT, see the included LICENSE file.

0.9.0

4 years ago

0.8.4

4 years ago

0.8.3

4 years ago

0.8.2

4 years ago

0.8.1

4 years ago

0.8.0

5 years ago

0.7.3

5 years ago

0.7.2

5 years ago

0.7.1

5 years ago

0.7.0

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.2

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago