Created
August 6, 2019 12:42
-
-
Save BretCameron/5d577a6a72bc9e4e1e1f6db87e5b8ad3 to your computer and use it in GitHub Desktop.
A Redux action that returns a function, which is made possible by Redux Thunk middleware
This file contains hidden or 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'; | |
| export const createCourse = (item) => { | |
| return function (dispatch) { | |
| return axios.post('create', item).then( | |
| res => dispatch({ type: 'CREATE_ITEM', payload: res.data }), | |
| error => console.log(error) | |
| ); | |
| }; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment