22 lines
589 B
TypeScript
22 lines
589 B
TypeScript
export async function getTransactionsHistory({ query }: { query: string }) {
|
|
const baseUrl = process.env.NEXT_PUBLIC_BASE_URL
|
|
? `${process.env.NEXT_PUBLIC_BASE_URL}`
|
|
: "http://localhost:4000";
|
|
const res = await fetch(
|
|
`${baseUrl}/api/dashboard/transactionsHistory?${query}`,
|
|
{
|
|
cache: "no-store",
|
|
}
|
|
);
|
|
|
|
if (!res.ok) {
|
|
// Handle error from the API
|
|
const errorData = await res
|
|
.json()
|
|
.catch(() => ({ message: "Unknown error" }));
|
|
throw new Error(errorData.message || `HTTP error! status: ${res.status}`);
|
|
}
|
|
|
|
return res.json();
|
|
}
|