+ client: handle 403 status

This commit is contained in:
Ildar Kamalov
2020-01-21 16:57:51 +03:00
committed by Simon Zolin
parent 080e1dd74e
commit 447080b422
2 changed files with 8 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
import axios from 'axios';
import { getPathWithQueryString } from '../helpers/helpers';
import { R_PATH_LAST_PART } from '../helpers/constants';
class Api {
baseUrl = 'control';
@@ -17,6 +18,12 @@ class Api {
console.error(error);
const errorPath = `${this.baseUrl}/${path}`;
if (error.response) {
if (error.response.status === 403) {
const loginPageUrl = window.location.href.replace(R_PATH_LAST_PART, '/login.html');
window.location.replace(loginPageUrl);
return false;
}
throw new Error(`${errorPath} | ${error.response.data} | ${error.response.status}`);
}
throw new Error(`${errorPath} | ${error.message ? error.message : error}`);