forked from ddrilling/asb_cloud_front
Токен для OpenAPI теперь задаётся асинхронным методом
This commit is contained in:
parent
d51a669937
commit
d92ba25089
55
src/App.js
55
src/App.js
@ -1,36 +1,41 @@
|
||||
import './styles/App.less'
|
||||
import {
|
||||
BrowserRouter as Router,
|
||||
Switch,
|
||||
Route} from "react-router-dom"
|
||||
import {ConfigProvider} from 'antd'
|
||||
import locale from "antd/lib/locale/ru_RU"
|
||||
import Login from './pages/Login'
|
||||
import Register from './pages/Register'
|
||||
import Main from './pages/Main'
|
||||
Route
|
||||
} from 'react-router-dom'
|
||||
import { ConfigProvider } from 'antd'
|
||||
import locale from 'antd/lib/locale/ru_RU'
|
||||
|
||||
import { OpenAPI } from './services/api'
|
||||
import { getUserToken } from './utils/storage'
|
||||
import { PrivateRoute } from './components/Private'
|
||||
|
||||
import Main from './pages/Main'
|
||||
import Login from './pages/Login'
|
||||
import Register from './pages/Register'
|
||||
|
||||
import './styles/App.less'
|
||||
|
||||
//OpenAPI.BASE = 'http://localhost:3000'
|
||||
OpenAPI.TOKEN = localStorage.getItem('token')
|
||||
OpenAPI.TOKEN = async () => getUserToken()
|
||||
OpenAPI.HEADERS = {'Content-Type': 'application/json'}
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
export const App = () => (
|
||||
<ConfigProvider locale={locale}>
|
||||
<Router>
|
||||
<Switch>
|
||||
<Route path={'/login'}>
|
||||
<Login />
|
||||
</Route>
|
||||
<Route path={'/register'}>
|
||||
<Register />
|
||||
</Route>
|
||||
<PrivateRoute path={'/'}>
|
||||
<Main />
|
||||
</PrivateRoute>
|
||||
</Switch>
|
||||
</Router>
|
||||
<Router>
|
||||
<Switch>
|
||||
<Route path={'/login'}>
|
||||
<Login />
|
||||
</Route>
|
||||
<Route path={'/register'}>
|
||||
<Register />
|
||||
</Route>
|
||||
<PrivateRoute path={'/'}>
|
||||
<Main />
|
||||
</PrivateRoute>
|
||||
</Switch>
|
||||
</Router>
|
||||
</ConfigProvider>
|
||||
);
|
||||
}
|
||||
)
|
||||
|
||||
export default App
|
||||
|
Loading…
Reference in New Issue
Block a user