Last active
April 1, 2020 15:36
-
-
Save Porter97/50e80d2cd4e541dd66000a6ee6722ca1 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 _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