getRegion: use v2 API

This commit is contained in:
Martín M
2020-10-26 21:17:01 -03:00
parent 82f152d624
commit b3655b095d
2 changed files with 2 additions and 6 deletions

View File

@@ -41,6 +41,6 @@ module.exports = {
this.apiKey = _get(response, 'data.user.apikey', '');
this.at = _get(response, 'data.at', '');
return response;
return response.data;
},
};

View File

@@ -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 {