UNPKG

tensaikit

Version:

An autonomous DeFi AI Agent Kit on Katana enabling AI agents to plan and execute on-chain financial operations.

24 lines (23 loc) 863 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fetchFromApi = void 0; const fetchFromApi = async (url, options = {}) => { try { const { method = "GET", headers = {}, body } = options; const response = await fetch(url, { method, headers: { "Content-Type": "application/json", ...headers }, ...(method === "POST" && body ? { body: JSON.stringify(body) } : {}), }); if (!response.ok) { const errorText = await response.text(); throw new Error(`API Error: ${response.status} ${response.statusText} - ${errorText}`); } const data = await response.json(); return data; } catch (error) { throw new Error(`Fetch failed for ${url}: ${error.message}`); } }; exports.fetchFromApi = fetchFromApi;