Backend: handle response on the frontend (#839)
This commit is contained in:
committed by
Alexander Zobnin
parent
0233ae7046
commit
0bb2f7c7d8
@@ -40,26 +40,10 @@ export class ZabbixAPIConnector {
|
|||||||
//////////////////////////
|
//////////////////////////
|
||||||
|
|
||||||
request(method, params) {
|
request(method, params) {
|
||||||
this.tsdbRequest(method, params).then(response => {
|
return this.tsdbRequest(method, params).then(response => {
|
||||||
const result = this.handleTsdbResponse(response);
|
const result = this.handleTsdbResponse(response);
|
||||||
console.log(result);
|
|
||||||
});
|
return result;
|
||||||
|
|
||||||
return this.zabbixAPICore.request(this.url, method, params, this.requestOptions, this.auth)
|
|
||||||
.catch(error => {
|
|
||||||
if (isNotAuthorized(error.data)) {
|
|
||||||
// Handle auth errors
|
|
||||||
this.loginErrorCount++;
|
|
||||||
if (this.loginErrorCount > this.maxLoginAttempts) {
|
|
||||||
this.loginErrorCount = 0;
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return this.loginOnce()
|
|
||||||
.then(() => this.request(method, params));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return Promise.reject(error);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user