@zencemarketing/web-sdk
Version:
ZenceMarketing Web SDK for push notifications, popups, and custom event tracking.
22 lines (17 loc) • 489 B
text/typescript
import CONFIG from "./config.js";
type HttpMethod = "GET" | "POST" | "PUT" | "DELETE";
async function apiRequest<T = any>(
endpoint: string,
method: HttpMethod = "GET",
data: Record<string, any> | null = null
): Promise<T> {
const response = await fetch(`${CONFIG.API_BASE_URL}/${endpoint}`, {
method,
headers: {
"Content-Type": "application/json",
},
body: data ? JSON.stringify(data) : null,
});
return response.json();
}
export default apiRequest;