Skip to content

Instantly share code, notes, and snippets.

@marr
Created March 31, 2016 18:23
Show Gist options
  • Save marr/b6221820b15a8bfd3aef00a8d58df2af to your computer and use it in GitHub Desktop.
Save marr/b6221820b15a8bfd3aef00a8d58df2af to your computer and use it in GitHub Desktop.
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