Move src to dashboard (#152)

This commit is contained in:
Pranav Raj S 2019-10-16 14:36:17 +05:30 committed by GitHub
parent 012a2743f2
commit 2783fb6006
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
187 changed files with 29 additions and 29 deletions

View file

@ -0,0 +1,29 @@
/* eslint no-console: 0 */
import constants from '../constants';
import Auth from '../api/auth';
import router from '../routes';
const parseErrorCode = error => {
const errorStatus = error.response ? error.response.status : undefined;
// 901, 902 are used to identify billing related issues
if ([901, 902].includes(errorStatus)) {
const name = Auth.isAdmin() ? 'billing' : 'billing_deactivated';
router.push({ name });
}
return Promise.reject(error);
};
export default axios => {
const wootApi = axios.create();
wootApi.defaults.baseURL = constants.apiURL;
// Add Auth Headers to requests if logged in
if (Auth.isLoggedIn()) {
Object.assign(wootApi.defaults.headers.common, Auth.getAuthData());
}
// Response parsing interceptor
wootApi.interceptors.response.use(
response => response,
error => parseErrorCode(error)
);
return wootApi;
};