Revize 9bfa1e39
Přidáno uživatelem Jaroslav Hrubý před asi 2 roky(ů)
webapp/utils/axios.ts | ||
---|---|---|
2 | 2 |
import Router from 'next/router'; |
3 | 3 |
import { StatusCodes } from 'http-status-codes'; |
4 | 4 |
import { getToken } from './login'; |
5 |
import { useContext } from 'react'; |
|
6 |
import { LoggedUserContext } from '../contexts/LoggedUserContext'; |
|
5 | 7 |
|
6 | 8 |
export const axios = axiosLib.create({ |
7 | 9 |
baseURL: 'https://localhost:7241', |
... | ... | |
24 | 26 |
const status = error?.response?.status; |
25 | 27 |
if (status === StatusCodes.UNAUTHORIZED) { |
26 | 28 |
console.log('Unauthorized, redirecting...'); |
27 |
|
|
29 |
localStorage.clear(); |
|
28 | 30 |
if (Router.pathname !== '/') { |
29 | 31 |
await Router.replace({ |
30 | 32 |
pathname: '/', |
Také k dispozici: Unified diff
Document assigning implemented