UNPKG

friday-sdk

Version:

Official JavaScript/TypeScript SDK for the Friday API

26 lines (25 loc) 796 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.APIClient = void 0; class APIClient { constructor(options) { this.apiKey = options.apiKey; this.baseUrl = options.baseUrl || "https://api.fridaydata.tech"; } async request(path, options = {}) { const res = await fetch(`${this.baseUrl}${path}`, { ...options, headers: { "Content-Type": "application/json", "X-API-Key": this.apiKey, ...(options.headers || {}), }, }); if (!res.ok) { const errorText = await res.text(); throw new Error(`API Error ${res.status}: ${errorText}`); } return res.json(); } } exports.APIClient = APIClient;