Created
June 1, 2019 10:33
-
-
Save madan712/edcf0318d1998314b419c611a083c811 to your computer and use it in GitHub Desktop.
AppAction.js - Example with React, Redux and Axios API
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 AppApi from './AppApi'; | |
export function updateName(name) { | |
return { type: 'UPDATE_NAME', name }; | |
} | |
function loadResponse(response) { | |
return { type: 'LOAD_RESPONSE', response }; | |
} | |
export function callSayHello(name) { | |
return function(dispatch) { | |
return AppApi.sayHello(name).then(response => { | |
dispatch(loadResponse(response)); | |
}).catch(error => { | |
console.log(error); | |
}); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment