Files
e8964ae3-6663-4fa2-ab40-f6f…/src/lib/teemdrop-api.ts
2026-05-12 22:50:01 +00:00

24 lines
762 B
TypeScript

const TEEMDROP_API_URL = process.env.NEXT_PUBLIC_TEEMDROP_API_URL || 'https://api.teemdrop.com';
const TEEMDROP_API_KEY = process.env.TEEMDROP_API_KEY;
export const teemdropRequest = async (endpoint: string, options: RequestInit = {}) => {
const headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${TEEMDROP_API_KEY}`,
...options.headers,
};
const response = await fetch(`${TEEMDROP_API_URL}${endpoint}`, {
...options,
headers,
});
if (!response.ok) {
throw new Error(`Teemdrop API error: ${response.statusText}`);
}
return response.json();
};
export const getProducts = () => teemdropRequest('/products');
export const getOrderDetails = (orderId: string) => teemdropRequest(`/orders/${orderId}`);