WFDASH-WEBAPP/src/lib/order-payment-client.ts

13 lines
588 B
TypeScript
Raw Normal View History

"use client";
import getPocketBase from "@/lib/pocketbase";
/** Browser-session authentication is distinct from the audit attribution header. */
export async function paymentFetch<T>(url: string, init?: RequestInit): Promise<T> {
const headers = new Headers(init?.headers);
headers.set("Authorization", `Bearer ${getPocketBase().authStore.token}`);
const response = await fetch(url, { ...init, headers, cache: "no-store" });
const result = await response.json();
if (!response.ok) throw new Error(result.error || `Request failed (${response.status})`);
return result as T;
}