24 lines
762 B
TypeScript
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}`); |