Skip to content

Instantly share code, notes, and snippets.

@Jossdz
Created September 5, 2018 03:16
Show Gist options
  • Save Jossdz/143ecde387e5b8c20b9d5baced3f667e to your computer and use it in GitHub Desktop.
Save Jossdz/143ecde387e5b8c20b9d5baced3f667e to your computer and use it in GitHub Desktop.
import axios from 'axios'
const baseUrl = `http://localhost:3000/auth`
export const newUser = (username, password) => {
return axios
.post(`${baseUrl}/signup`,{
username,
password
})
}
export const login = (username, password) => {
return axios
.post(`${baseUrl}/login`, {
username,
password
})
}
export const logout = () => {
return axios
.get(`${baseUrl}/logout`)
.then(localStorage.removeItem('username'))
.then(document.location.reload())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment