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