当我console.log
然后发现undefined
时,我试图从存储中获取用于设置默认令牌axios的状态。
这是我的代码axiosConfig.js:
import axios from 'axios'
import _ from 'lodash'
const BASE_URL = '********.com'
import store from '../store'
console.log('store', store)
const instance = axios.create({
baseURL: BASE_URL
})
export { instance }
这是我的代码store.js:
import { createStore, applyMiddleware } from 'redux'
import 'regenerator-runtime/runtime'
import createSagaMiddleware from 'redux-saga'
import rootSaga from './sagas'
import rootReducer from './reducers/index'
import { routerMiddleware } from 'react-router-redux'
import { createBrowserHistory } from 'history'
import logger from 'redux-logger'
export const history = createBrowserHistory()
export const defaultState = {}
const sagaMiddleware = createSagaMiddleware()
const store = createStore(rootReducer, defaultState, applyMiddleware(sagaMiddleware, routerMiddleware(history)))
sagaMiddleware.run(rootSaga)
export default store
错误:
store undefined