0.1.4 • Published 9 years ago
@praekelt/seed-auth v0.1.4
seed-auth-js
js client for seed-auth-api
install
$ npm install @praekelt/seed-authusage
const auth = require('@praekelt/seed-auth');
auth.users.list()
.then(res => console.log(resp.data));api
configuration
Configuration can be provided as an options object for each api method:
auth.users.list({conf: {token: '1234'}});or set for all api methods:
auth.conf.token = '1234';conf.prefix
The prefix to use for requests. Defaults to http://localhost:8000.
conf.token
The authentication token to use for requests.
query params
Query params for api methods can be provided directly in the options object for each api method:
auth.users.list({archived: true});pagination
The result object contains next(), prev(), hasNext() and hasPrev() methods for traversing paginated results:
auth.users.list({
page: 1,
page_size: 2
})
.then(res => {
// `true` if there is a next page, otherwise `false`
console.log(res.hasNext());
// `true` if there is a previous page, otherwise `false`
console.log(res.hasPrev());
return res
})
.then(res => res.next()) // next page (or `null` if there is no next page)
.then(res => res.prev()); // prev page (or `null` if there is no prev page)