Skip to content

Instantly share code, notes, and snippets.

@itsanna
Last active May 4, 2016 23:03
Show Gist options
  • Save itsanna/7bd148b0c61c75e2251e2bd27299d09e to your computer and use it in GitHub Desktop.
Save itsanna/7bd148b0c61c75e2251e2bd27299d09e to your computer and use it in GitHub Desktop.
import 'whatwg-fetch'
const GITHUB_API = 'https://api.github.com'
function receiveUser (name, json) {
return {
type: 'RECEIVE_USER',
user: json
}
}
export function fetchUser ({username}) {
return (dispatch) => {
return fetch(`${GITHUB_API}/users/${username}`)
.then(processResponse)
.then(json => dispatch(receiveUser(username, json)))
.catch(error => console.log(error))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment