Add src/lib/teemdrop-api.ts

This commit is contained in:
2026-05-12 22:50:01 +00:00
parent b585c9a84c
commit d73c7ef2bc

24
src/lib/teemdrop-api.ts Normal file
View File

@@ -0,0 +1,24 @@
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}`);