Created
October 28, 2017 21:31
-
-
Save salujaharkirat/6df8a9e90d44a9cbfacee89f7710dc16 to your computer and use it in GitHub Desktop.
Redux thunk actions
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"; | |
| 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