trello_fake/lib/dolibarrClient.ts

12 lines
404 B
TypeScript

export async function dolibarrFetch(endpoint: string, options: RequestInit = {}) {
const url = `${process.env.NEXT_PUBLIC_API_URL}/${endpoint}?DOLAPIKEY=${process.env.NEXT_PUBLIC_DOLIBARR_API_KEY}`;
const res = await fetch(url);
if (!res.ok) {
console.error("Error en la llamada Dolibarr:", res.status, await res.text());
throw new Error("Dolibarr API error");
}
return res.json();
}