Created
March 31, 2016 18:23
-
-
Save marr/b6221820b15a8bfd3aef00a8d58df2af to your computer and use it in GitHub Desktop.
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
export function changeUser(user) { | |
const personId = user.person_id | |
return (dispatch, getState) => { | |
dispatch({ type: CHANGE_USER, payload: { personId } }) | |
const peopleEndpoint = PEOPLE_ENDPOINT(personId).clone() | |
return secureFetch(peopleEndpoint, { | |
method: 'PATCH', | |
body: JSON.stringify(user) | |
}).then( | |
res => dispatch(changedUser(user)), // I think i need to combine this user with getState().user | |
error => dispatch(changeUserError(error, personId)) | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment