Skip to content

Instantly share code, notes, and snippets.

@madan712
Created June 1, 2019 10:33
Show Gist options
  • Save madan712/edcf0318d1998314b419c611a083c811 to your computer and use it in GitHub Desktop.
Save madan712/edcf0318d1998314b419c611a083c811 to your computer and use it in GitHub Desktop.
AppAction.js - Example with React, Redux and Axios API
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