Skip to content

Instantly share code, notes, and snippets.

@camwhite
Created July 8, 2019 23:58
Show Gist options
  • Save camwhite/d2fabb5afa969635130683b7331ffb0b to your computer and use it in GitHub Desktop.
Save camwhite/d2fabb5afa969635130683b7331ffb0b to your computer and use it in GitHub Desktop.
export const getCurrentUser = () => (dispatch, getState) => {
const { currentUser } = getState().authenticationRequest
if (currentUser) {
return dispatch({
type: 'CURRENT_USER_SUCCESS',
currentUser
})
}
dispatch({
type: 'CURRENT_USER_REQUEST'
})
return fetchCurrentUser()
.then(currentUser => {
dispatch({
type: 'CURRENT_USER_SUCCESS',
currentUser
})
})
.catch(err => {
dispatch({
type: 'CURRENT_USER_FAILURE',
err: err
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment