Skip to main content
Glama
oofengoo

MCP-Serve 多语言翻译服务

by oofengoo
request.ts2.21 kB
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; import { IAXIOS } from './typings'; class AXIOS implements IAXIOS { private axiosInstance: AxiosInstance; constructor(options: AxiosRequestConfig) { this.axiosInstance = axios.create(options); } request(config: AxiosRequestConfig): Promise<any> { return new Promise((resolve, reject) => { this.axiosInstance .request(config) .then((res) => { let status = res.status; if (status === 200) { // 如果是stream类型,直接返回整个响应对象 if (config.responseType === 'stream') { resolve(res); } else { let result = res.data; resolve(result); } } }) .catch((e) => { reject(e); }); }); } get(url: string, data?: any, config: AxiosRequestConfig = {}): Promise<any> { return this.request({ url, method: 'get', baseURL: config.baseURL, headers: config.headers, params: data, data: null, responseType: config.responseType || 'json', }); } post(url: string, data: any, config: AxiosRequestConfig = {}): Promise<any> { return this.request({ url, method: 'post', headers: config.headers, baseURL: config.baseURL, responseType: config.responseType || 'json', params: null, data: data, }); } } function createAxios(opt: { baseUrl?: string; token?: string }): AXIOS { const config: AxiosRequestConfig = { baseURL: opt.baseUrl, timeout: 10 * 1000, headers: { 'Cookie': opt.token, // 添加 token 到请求头 'Content-Type': 'application/json' // 或者其他你需要的请求头 } }; return new AXIOS(config); } export default createAxios({})

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/oofengoo/mcp-serve-learn'

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