refactor: clean code

This commit is contained in:
Fu Diwei
2024-12-23 19:31:48 +08:00
parent d509445519
commit 9ef16ebcf9
6 changed files with 21 additions and 9 deletions

View File

@@ -1,4 +1,6 @@
import { Statistics } from "@/domain/statistics";
import { ClientResponseError } from "pocketbase";
import { type Statistics } from "@/domain/statistics";
import { getPocketBase } from "@/repository/pocketbase";
export const get = async () => {
@@ -8,8 +10,8 @@ export const get = async () => {
method: "GET",
});
if (resp.code !== 0) {
throw new Error(resp.msg);
if (resp.status != 0 && resp.status !== 200) {
throw new ClientResponseError({ status: resp.status, response: resp, data: {} });
}
return resp.data as Statistics;