I have the following action
export function getAllBooks() {
return function(dispatch) {
return axios.get('http://localhost:8080/books')
.then(response => dispatch(retrieveBooks(response.data)));
};
}
The issue is when i call this action, I get in the console
Uncaught (in promise) TypeError: dispatch is not a function at eval (eval at ...
that is the dispatch
in the .then(response => dispatch(retrieveBooks(response.data)));
is playing up
I've tried removing all other middle-ware except redux-thunk to no avail
The only place the action is used is in
const mapDispatchToProps = (dispatch) => {
return { fetchBooks : () => dispatch(getAllBooks) };
}
You need to call the
getAllBooks
action creator and pass the inner function todispatch