mirror of
https://github.com/skydiver/ewelink-api.git
synced 2025-12-30 09:45:10 +01:00
getRegion: use v2 API
This commit is contained in:
@@ -41,6 +41,6 @@ module.exports = {
|
||||
this.apiKey = _get(response, 'data.user.apikey', '');
|
||||
this.at = _get(response, 'data.at', '');
|
||||
|
||||
return response;
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -3,16 +3,12 @@ const errors = require('../data/errors');
|
||||
|
||||
module.exports = {
|
||||
async getRegion() {
|
||||
if (!this.email || !this.password) {
|
||||
return { error: 406, msg: errors.invalidAuth };
|
||||
}
|
||||
|
||||
const credentials = await this.getCredentials();
|
||||
|
||||
const error = _get(credentials, 'error', false);
|
||||
|
||||
if (error) {
|
||||
return credentials;
|
||||
throw new Error(`[${error}] ${errors[error]}`);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user