How to use losant-rest - 2 common examples

To help you get started, we’ve selected a few losant-rest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Losant / losant-rest-js / examples / auth.js View on Github external
var api = require('losant-rest');
var client = api.createClient();

// using callbacks
client.auth.authenticateUser({ credentials:
  { email: 'example@losant.com', password: 'your_password' } },
  function (err, response) {
    if (err) { return console.error(err); }
    console.log(response);
  }
);
/* Example user result
 * {
 *   token: 'an auth token string',
 *   userId: 'theUserId'
 * }
 */
github Losant / losant-rest-js / examples / list_devices.js View on Github external
var api = require('losant-rest');

var client = api.createClient({ accessToken: 'my_token' });
client.devices.get({ applicationId: 'myAppId' })
.then(function (response) {
  console.log(response);
})
.catch(function (err) {
  console.error(err);
});
/* Example result
 * {
 *   count: 1,
 *   items: [ {
 *     deviceClass: 'standalone',
 *     connectionInfo: { connected: 0, time: '2016-06-01T17:16:02.324Z' },
 *     name: 'Ruby Client Testing',
 *     creationDate: '2016-01-31T17:58:57.541Z',
 *     lastUpdated: '2016-05-31T14:47:32.288Z',

losant-rest

REST client for accessing the Losant API

MIT
Latest version published 18 days ago

Package Health Score

63 / 100
Full package analysis

Popular losant-rest functions