Skip to content

Instantly share code, notes, and snippets.

@Porter97
Last active April 1, 2020 15:36
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 Porter97/50e80d2cd4e541dd66000a6ee6722ca1 to your computer and use it in GitHub Desktop.
Save Porter97/50e80d2cd4e541dd66000a6ee6722ca1 to your computer and use it in GitHub Desktop.
import _superagent from 'superagent';
import superagentPromise from 'superagent-promise';
const superagent = superagentPromise(_superagent, global.Promise);
const API_ROOT = 'http://127.0.0.1:5000';
const responseBody = res => res.body;
const agent = {
get: url =>
superagent.get(`${API_ROOT}${url}`).then(responseBody),
post: (url, form) =>
superagent.post(`${API_ROOT}${url}`).type('form').send(form).then(responseBody)
};
const Auth = {
current: () =>
agent.get('/user'),
register: (email, username, password, password2) =>
agent.post('/auth/register', { email, username, password, password2 }),
};
export default {
Auth
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment