Skip to content

Instantly share code, notes, and snippets.

@tribou
Last active October 14, 2015 04:09
Show Gist options
  • Save tribou/b736a59c64d12b34b0ee to your computer and use it in GitHub Desktop.
Save tribou/b736a59c64d12b34b0ee to your computer and use it in GitHub Desktop.
A sample React API utility implemented in ES6
// 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