Skip to main content
Glama
requests.ts853 B
import type { RequestsResponse } from '../types/request'; import { ApiError } from './errors'; const API_BASE = '/api'; export async function fetchRequests(sourceId?: string): Promise<RequestsResponse> { try { const url = sourceId ? `${API_BASE}/requests?source_id=${encodeURIComponent(sourceId)}` : `${API_BASE}/requests`; const response = await fetch(url); if (!response.ok) { const errorMessage = await response .json() .then((data) => data.error) .catch(() => response.statusText); throw new ApiError(`Failed to fetch requests: ${errorMessage}`, response.status, response.statusText); } return response.json(); } catch (err) { if (err instanceof ApiError) { throw err; } throw new ApiError(err instanceof Error ? err.message : 'Network error', 0); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bytebase/dbhub'

If you have feedback or need assistance with the MCP directory API, please join our Discord server