fix: linting

This commit is contained in:
tiagosiebler
2020-10-04 20:37:42 +01:00
parent 3a2125e77b
commit 1b556afeb3
2 changed files with 23 additions and 29 deletions

View File

@@ -15,7 +15,6 @@ module.exports = {
indent: ['warn', 2],
'linebreak-style': ['error', 'unix'],
'lines-between-class-members': ['warn', 'always'],
quotes: ['error', 'single'],
semi: ['error', 'always'],
'new-cap': 'off',
'no-console': 'off',

View File

@@ -24,7 +24,7 @@ module.exports = class RequestUtil {
this.baseUrl = baseUrls[livenet === true ? 'livenet' : 'testnet'];
if (options.baseUrl) {
this.baseUrl = options.baseUrl
this.baseUrl = options.baseUrl;
}
this.globalRequestOptions = {
@@ -35,7 +35,7 @@ module.exports = class RequestUtil {
headers: {
Referer: 'bybitapinode'
},
}
};
if (key) {
assert(secret, 'Secret is required for private enpoints');
@@ -108,27 +108,27 @@ module.exports = class RequestUtil {
requestOptions: options
};
})
.catch(e => {
if (!e.response) {
.catch(e => {
if (!e.response) {
// Something happened in setting up the request that triggered an Error
if (!e.request) {
throw e.message;
if (!e.request) {
throw e.message;
}
// request made but no response received
throw e;
}
// request made but no response received
throw e;
}
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
throw {
code: e.response.statusCode,
message: e.response.message,
body: e.response.body,
requestOptions: options,
headers: e.response.headers
};
});
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
throw {
code: e.response.statusCode,
message: e.response.message,
body: e.response.body,
requestOptions: options,
headers: e.response.headers
};
});
}
_signRequest(data) {
@@ -156,14 +156,9 @@ module.exports = class RequestUtil {
return this._syncTimePromise;
}
this._syncTimePromise = new Promise(async (resolve, reject) => {
try {
this._timeOffset = await this.getTimeOffset();
this._syncTimePromise = null;
resolve();
} catch (err) {
reject(err);
}
this._syncTimePromise = this.getTimeOffset().then(offset => {
this._timeOffset = offset;
this._syncTimePromise = null;
});
return this._syncTimePromise;