mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 02:33:01 +00:00
27 lines
656 B
TypeScript
27 lines
656 B
TypeScript
import { getServerURL } from "@/lib/utils";
|
|
import type { ServerQueryInput } from "..";
|
|
|
|
export async function byProject({
|
|
projectId,
|
|
onSuccess,
|
|
onError,
|
|
}: {
|
|
projectId: number;
|
|
} & ServerQueryInput) {
|
|
const url = new URL(`${getServerURL()}/issues/by-project`);
|
|
url.searchParams.set("projectId", `${projectId}`);
|
|
|
|
const res = await fetch(url.toString(), {
|
|
credentials: "include",
|
|
});
|
|
|
|
if (!res.ok) {
|
|
const error = await res.text();
|
|
onError?.(error || `failed to get issues by project (${res.status})`);
|
|
} else {
|
|
const data = await res.json();
|
|
|
|
onSuccess?.(data, res);
|
|
}
|
|
}
|