Skip to content

Instantly share code, notes, and snippets.

@salujaharkirat
Created October 28, 2017 21:31
Show Gist options
  • Select an option

  • Save salujaharkirat/6df8a9e90d44a9cbfacee89f7710dc16 to your computer and use it in GitHub Desktop.

Select an option

Save salujaharkirat/6df8a9e90d44a9cbfacee89f7710dc16 to your computer and use it in GitHub Desktop.
Redux thunk actions
import axios from "axios";
import API_END_POINT from "../config/index";
const fetchCharacters = () => {
return (dispatch) => {
axios.get(API_END_POINT)
.then((response) => {
dispatch(receiveCharacters(response.data.results));
})
.catch((error) => {
console.warn("error", error);
});
};
};
const receiveCharacters = (payload) => {
return {
type: "RECEIVE_CHARACTERS",
payload
};
}
export {
fetchCharacters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment