Skip to content

Instantly share code, notes, and snippets.

@apotox
Created March 16, 2020 19:45
Show Gist options
  • Save apotox/fa43fa0b846c2144c80d3043961565d4 to your computer and use it in GitHub Desktop.
Save apotox/fa43fa0b846c2144c80d3043961565d4 to your computer and use it in GitHub Desktop.
redux store with thunk middleware and extra Axios parameter
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