Commit 8e471a6d authored by Simic Veljko's avatar Simic Veljko
Browse files

Handle unauthorized status

parent ffad28e1
......@@ -45,7 +45,14 @@ export const fetchApi = (args)=>{
if (!isLoggedIn()) {
delete newargs.headers.Authorization;
}
return axios(newargs).then(response => {
return axios(newargs)
.then(response => {
console.log(`[response] ${response}`);
return response.data;
}).catch(error => {
if(error.response.status === 401 && isLoggedIn()){
logOut();
window.history.go('/login');
}
});
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment