feat: clearly fetcher implement

This commit is contained in:
DarkSky
2022-12-22 15:40:25 +08:00
committed by DarkSky
parent b666fd8d0a
commit adede32af2
5 changed files with 76 additions and 146 deletions
+4 -13
View File
@@ -27,13 +27,9 @@ export interface LoginResponse {
}
export async function login(params: LoginParams): Promise<LoginResponse> {
const data = await request<LoginResponse>({
url: '/api/user/token',
method: 'POST',
data: params,
withAuthorization: false,
} as any);
return data.data;
return request
.post('/api/user/token', { json: params, headers: { token: undefined } })
.json<LoginResponse>();
}
export interface GetUserByEmailParams {
@@ -52,10 +48,5 @@ export interface User {
export async function getUserByEmail(
params: GetUserByEmailParams
): Promise<User | null> {
const data = await request<User | null>({
url: '/api/user',
method: 'GET',
params,
});
return data.data;
return request.get('/api/user', { json: params }).json<User | null>();
}