Skip to main content
Glama
fetching-axios.ts1.19 kB
/** * Axios HTTP Fetching Strategy * * Simple HTTP GET requests for direct documentation URLs. */ import { Metadata } from "@superglue/shared"; import axios from "axios"; import { server_defaults } from '../../default.js'; import { logMessage } from "../../utils/logs.js"; import { DocumentationConfig, DocumentationFetchingStrategy } from '../types.js'; export class AxiosFetchingStrategy implements DocumentationFetchingStrategy { async tryFetch(config: DocumentationConfig, metadata: Metadata): Promise<string | null> { if (!config.documentationUrl?.startsWith("http")) return null; try { const url = new URL(config.documentationUrl); if (config.queryParams) { Object.entries(config.queryParams).forEach(([key, value]) => { url?.searchParams?.append(key, value); }); } const response = await axios.get(url.toString(), { headers: config.headers, timeout: server_defaults.DOCUMENTATION.TIMEOUTS.AXIOS }); let data = response.data; return data; } catch (error) { logMessage('warn', `Axios fetch failed for ${config.documentationUrl}: ${error?.message}`, metadata); return null; } } }

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/superglue-ai/superglue'

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