fixed bug with undefined variable

This commit is contained in:
Martín M
2019-06-26 21:49:31 -03:00
parent a5e338d1ef
commit d8971ee2b5
2 changed files with 5 additions and 3 deletions

View File

@@ -3,12 +3,14 @@ const W3CWebSocket = require('websocket').w3cwebsocket;
const WebSocketAsPromised = require('websocket-as-promised'); const WebSocketAsPromised = require('websocket-as-promised');
const delay = require('delay'); const delay = require('delay');
const { _get } = require('./lib/helpers');
const { const {
makeAuthorizationSign, makeAuthorizationSign,
loginPayload, loginPayload,
wssLoginPayload, wssLoginPayload,
wssUpdatePayload, wssUpdatePayload,
} = require('./lib/helper'); } = require('./lib/ewelink-helper');
class eWeLink { class eWeLink {
constructor({ region = 'us', email, password }) { constructor({ region = 'us', email, password }) {
@@ -51,8 +53,8 @@ class eWeLink {
body, body,
json: true, json: true,
}); });
this.apiKey = response.user.apikey; this.apiKey = _get(response, 'user.apikey', '');
this.at = response.at; this.at = _get(response, 'at', '');
return response; return response;
} }