refactor
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import type { ApiEnvelope } from "@/types/api";
|
||||
|
||||
export class ApiError extends Error {
|
||||
status: number;
|
||||
body: string;
|
||||
@@ -12,13 +14,6 @@ export class ApiError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
type ApiEnvelope<T> = {
|
||||
status: "success" | "error" | string;
|
||||
data: T;
|
||||
message: string;
|
||||
errors: unknown[];
|
||||
};
|
||||
|
||||
export async function requestJson<T>(input: RequestInfo | URL, init?: RequestInit): Promise<T> {
|
||||
const res = await fetch(input, init);
|
||||
const payload = await parseJsonResponse(res);
|
||||
|
||||
Reference in New Issue
Block a user