better errors

This commit is contained in:
2022-10-26 00:16:41 +02:00
parent 78addafe18
commit 0f53063832
6 changed files with 42 additions and 25 deletions

View File

@ -1,22 +1,18 @@
import type { CreateUserBody, LoginUserBody, UserInfo } from '@core';
import { post, get } from './request';
import { currentUser } from '../store/user';
export async function login(raw: LoginUserBody) {
const user = await post<UserInfo>('/user/login', raw);
currentUser.set(user);
return user;
return post<UserInfo>('/user/login', raw);
}
export async function logout() {
await post('/user/logout');
currentUser.set(null);
await post<void>('/user/logout');
}
export async function read(uuid: string) {
const user = await get<UserInfo>(`/user/read/${uuid}`);
return get<UserInfo>(`/user/read/${uuid}`);
}
export async function create(raw: CreateUserBody) {
const user = await post<UserInfo>('/user/create', raw);
return post<UserInfo>('/user/create', raw);
}