Move api calls into services

This commit is contained in:
jwu-fisker
2021-01-06 09:23:19 -08:00
parent db75494dd8
commit 002bad0a91
2 changed files with 37 additions and 35 deletions

33
src/services/auth.js Normal file
View File

@@ -0,0 +1,33 @@
const AUTH_URL = 'https://dev-auth.fiskerdps.com';
export default {
signIn: (username, password) => fetch(`${AUTH_URL}/auth/login`, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
username,
password,
})
}).then((response) => response.json()),
signUp: (username, password) => fetch(`${AUTH_URL}/auth/register`, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
username,
password,
})
}).then((response) => response.json()),
verify: (jwt) => fetch(`${AUTH_URL}/auth/verify`, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ token: jwt })
}).then((response) => response.json()),
}