"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const getCookieSession_1 = tslib_1.__importDefault(require("./getCookieSession"));
async function PHXFetchAPI(url, options) {
    try {
        const cookieSession = (0, getCookieSession_1.default)();
        const { method, body } = options;
        const response = await fetch(url, {
            method,
            headers: {
                Authorization: 'Bearer' + ' ' + (cookieSession === null || cookieSession === void 0 ? void 0 : cookieSession.access_token),
                'Content-Type': 'application/json',
            },
            body,
        });
        if (!response.ok) {
            throw new Error(`HTTP error! Status: ${response.status}`);
        }
        return await response.json();
    }
    catch (error) {
        console.error('Error calling API:', error);
        throw error;
    }
}
exports.default = PHXFetchAPI;
//# sourceMappingURL=serverQuery.js.map