Last active
May 4, 2016 23:03
-
-
Save itsanna/7bd148b0c61c75e2251e2bd27299d09e to your computer and use it in GitHub Desktop.
This file contains 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
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