mirror of
https://github.com/ershisan99/todolist_next.git
synced 2026-01-30 21:02:05 +00:00
initial commit, login page
This commit is contained in:
30
src/services/index.ts
Normal file
30
src/services/index.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { instance } from "./instance";
|
||||
|
||||
const handleError = (data: any) => {
|
||||
if (data.resultCode === 0) {
|
||||
return data;
|
||||
} else {
|
||||
throw new Error(data.messages[0]);
|
||||
}
|
||||
};
|
||||
|
||||
export type PostLoginArgs = {
|
||||
email: string;
|
||||
password: string;
|
||||
rememberMe: boolean;
|
||||
};
|
||||
|
||||
export const postLogin = async (args: PostLoginArgs) => {
|
||||
const data = await instance.post("auth/login", args);
|
||||
return handleError(data.data);
|
||||
};
|
||||
|
||||
export const getMe = async () => {
|
||||
const data = await instance.get("auth/me");
|
||||
return handleError(data.data);
|
||||
};
|
||||
|
||||
export const deleteMe = async () => {
|
||||
const data = await instance.delete("auth/login");
|
||||
return handleError(data.data);
|
||||
};
|
||||
Reference in New Issue
Block a user