Last active
October 14, 2015 04:09
-
-
Save tribou/b736a59c64d12b34b0ee to your computer and use it in GitHub Desktop.
A sample React API utility implemented in ES6
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
// Random User API logic | |
import { receiveRandom } from '../actions/TodoServerActions'; | |
import request from 'superagent'; | |
export function getRandomApi() { | |
request.get('http://api.randomuser.me/') | |
.set('Accept', 'application/json') | |
.end((err, response) => { | |
if (err) return console.error(err); | |
receiveRandom(response.body); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment