Created
March 16, 2020 19:45
-
-
Save apotox/fa43fa0b846c2144c80d3043961565d4 to your computer and use it in GitHub Desktop.
redux store with thunk middleware and extra Axios parameter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios' | |
import {combineReducers, createStore, applyMiddleware} from 'redux' | |
import thunk from 'redux-thunk' | |
import listTodoReducer from './components/ListTodo/ListTodo.reducer' | |
const API_ENDPOINT = "https://api...." | |
//combine project reducers | |
const reducers = combineReducers({ | |
listTodoReducer | |
}); | |
const api = axios.create({ | |
headers:{ | |
authorization: 'TOKEN' | |
}, | |
baseURL: `${API_ENDPOINT}/` | |
}) | |
const store = createStore( | |
reducers, | |
applyMiddleware(thunk.withExtraArgument(api)) | |
); | |
export default store |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment