1.1.0 • Published 5 years ago

@yeep/client v1.1.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 years ago

Yeep JavaScript Client

Yeep API client for Node.js and the browser.

Build Status npm version

Features

  • Works with Node.js v.6+ or any modern browser (incl. ie11);
  • Exposes promise-based API (supports async/await);
  • Manages session renewal automatically;
  • Implements Yeep API methods, exactly matching naming scheme.

Installation

$ npm install @yeep/client

Quick start

Create yeep client

const YeepClient = require('@yeep/client');

const yeep = new YeepClient({
  baseURL: 'https://yeep.acme.com', // replace this with your own domain
});

Create session to use with authenticated API requests, a.k.a. login

yeep
  .login({
    user: 'coyote@acme.com',
    password: 'catch-the-b1rd$',
  })
  .then((data) => {
    // do something with session data
  })
  .catch((err) => {
    // handle error
  });

Make an API call

yeep
  .api() // retrieve api object - this is async, i.e. returns promise
  .then((api) => {
    // make api call
    return api.user.info({
      id: '507f191e810c19729de860ea',
      projection: {
        permissions: true,
        roles: true,
      },
    });
  })
  .then((data) => {
    // do something with user info data
  })
  .catch((err) => {
    // handle error
  });

Destroy an existing session, a.k.a. logout

yeep
  .logout()
  .then(() => {
    // handle successful logout
  })
  .catch((err) => {
    // handle error
  });

License

Apache 2.0

1.1.0

5 years ago

1.1.0-beta.7

5 years ago

1.1.0-beta.6

5 years ago

1.1.0-beta.5

5 years ago

1.1.0-beta.4

5 years ago

1.1.0-beta.3

5 years ago

1.1.0-beta.2

5 years ago

1.1.0-beta.1

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago