Skip to content

Instantly share code, notes, and snippets.

@BretCameron
Created August 6, 2019 12:42
Show Gist options
  • Select an option

  • Save BretCameron/5d577a6a72bc9e4e1e1f6db87e5b8ad3 to your computer and use it in GitHub Desktop.

Select an option

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
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