ts-quiz— ~/quiz/levels.ts
tsc --watch● loading…
// tsc --watch · type-checking modules…
await load("quiz/levels.ts")
// streaming server components
◇ tsc 6.0.3 · compiling…UTF-8◇ scanning levels…
res.data im success-Block und res.message im error-Block?type ApiResponse<T> =
| { status: "success"; data: T; timestamp: number }
| { status: "error"; message: string; code: number }
| { status: "loading" };
function handleResponse(res: ApiResponse<string[]>) {
if (res.status === "success") {
console.log(res.data.join(", "));
} else if (res.status === "error") {
console.log(res.message);
}
}