36 lines
635 B
TypeScript
36 lines
635 B
TypeScript
|
|
import { useHttp } from "@/modules/http";
|
|
import axios from "axios";
|
|
|
|
const { post } = useHttp();
|
|
|
|
export const submit =
|
|
async (email: string, password: string) => (
|
|
|
|
await post('/account/login', {
|
|
email,
|
|
password
|
|
})
|
|
|
|
)
|
|
|
|
|
|
export const logout =
|
|
async (): Promise<null | Error> => (await post('/account/logout'));
|
|
|
|
|
|
|
|
export const fetchProfile = async(email: string, token: string) => (
|
|
|
|
await axios({
|
|
url: "http://127.0.0.1:3000/api/account/profile",
|
|
headers: {
|
|
Cookie: `jwt=${token}`
|
|
},
|
|
method: 'GET',
|
|
data: {
|
|
email,
|
|
}
|
|
})
|
|
)
|
|
|