Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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'
* }
*/
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',