多种实现 | Multiple Implementations
支持 Fetch 和 Axios 两种实现,可根据需求自由切换。Supports both Fetch and Axios implementations, switch freely based on your needs.
模块化、可扩展的现代 HTTP 请求库 | A modern, modular, and extensible HTTP request library
npm install @ureq/core @ureq/impl-fetchpnpm add @ureq/core @ureq/impl-fetchyarn add @ureq/core @ureq/impl-fetchimport { Request } from '@ureq/core';
import { FetchRequestor } from '@ureq/impl-fetch';
// 创建请求实例
const request = new Request(new FetchRequestor({
baseURL: 'https://jsonplaceholder.typicode.com/todos/1'
}));
// 发起请求
const data = await request.get('/users/1');
console.log(data);核心功能与具体实现分离,按需引入所需模块,保持应用轻量。
Separates core functionality from implementation, import only what you need.
轻松添加自定义请求器、拦截器和功能模块。
Easily add custom requestors, interceptors, and feature modules.
内置常用功能如重试、缓存、超时等,无需额外配置。
Built-in features like retry, cache, timeout with no extra config.
完整的 TypeScript 支持,享受智能提示和类型检查。
Full TypeScript support with intelligent hints and type checking.