Skip to content

Instantly share code, notes, and snippets.

@hedgerh
Created January 22, 2019 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hedgerh/79fa384b64eec95c37a3f278a39bb390 to your computer and use it in GitHub Desktop.
Save hedgerh/79fa384b64eec95c37a3f278a39bb390 to your computer and use it in GitHub Desktop.
import httpClient from './httpClient'
const login = (email, password) => (dispatch) => {
return httpClient.login(email, password)
.then(response => {
httpClient.token = response.token
dispatch(loginSuccess(response))
})
}
const refreshToken = () => (dispatch) => {
httpClient.refreshToken()
.then(token => {
httpClient.token = token
dispatch(refreshTokenSuccess(token)
})
}
import HttpClient from './HttpClient'
// export an instance, aka a "Singleton", of HttpClient
export default new HttpClient()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment