ky
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese该 skill 基于 Ky v1.14.3,生成于 2026-02-04。
Ky is a tiny and elegant HTTP client based on the Fetch API. It provides a simpler and more powerful API than plain fetch with no dependencies, targeting modern browsers, Node.js 18+, Bun, and Deno.
该 skill 基于 Ky v1.14.3,生成于 2026-02-04。
Ky是一款基于Fetch API的轻量优雅HTTP客户端。它无需依赖,提供了比原生fetch更简洁且功能更强大的API,适用于现代浏览器、Node.js 18+、Bun和Deno。
Core References
核心参考
| Topic | Description | Reference |
|---|---|---|
| Basic Usage | HTTP method shortcuts, response body methods, TypeScript support | core-usage |
| Core Options | json, searchParams, prefixUrl, timeout, method | core-options |
| 主题 | 描述 | 参考 |
|---|---|---|
| 基础用法 | HTTP方法快捷方式、响应体处理方法、TypeScript支持 | core-usage |
| 核心选项 | json、searchParams、prefixUrl、timeout、method | core-options |
Features
功能特性
Retry Mechanism
重试机制
| Topic | Description | Reference |
|---|---|---|
| Automatic Retry | Configurable retry strategies, delays, jitter, custom logic | feature-retry |
| 主题 | 描述 | 参考 |
|---|---|---|
| 自动重试 | 可配置的重试策略、延迟、抖动、自定义逻辑 | feature-retry |
Hooks System
钩子系统
| Topic | Description | Reference |
|---|---|---|
| Lifecycle Hooks | beforeRequest, beforeRetry, afterResponse, beforeError hooks | feature-hooks |
| 主题 | 描述 | 参考 |
|---|---|---|
| 生命周期钩子 | beforeRequest、beforeRetry、afterResponse、beforeError钩子 | feature-hooks |
Instance Management
实例管理
| Topic | Description | Reference |
|---|---|---|
| Custom Instances | ky.create(), ky.extend(), context for hooks | feature-instances |
| 主题 | 描述 | 参考 |
|---|---|---|
| 自定义实例 | ky.create()、ky.extend()、钩子上下文 | feature-instances |
Error Handling
错误处理
| Topic | Description | Reference |
|---|---|---|
| Error Types | HTTPError, TimeoutError, ForceRetryError, type guards | feature-errors |
| 主题 | 描述 | 参考 |
|---|---|---|
| 错误类型 | HTTPError、TimeoutError、ForceRetryError、类型守卫 | feature-errors |
Advanced
进阶功能
| Topic | Description | Reference |
|---|---|---|
| Progress Tracking | Upload and download progress callbacks | advanced-progress |
| Customization | Custom JSON parsing/stringifying, custom fetch | advanced-customization |
| 主题 | 描述 | 参考 |
|---|---|---|
| 进度追踪 | 上传和下载进度回调 | advanced-progress |
| 自定义配置 | 自定义JSON解析/序列化、自定义fetch | advanced-customization |
Best Practices
最佳实践
| Topic | Description | Reference |
|---|---|---|
| Form Data | multipart/form-data, URL-encoded forms, file upload | best-practices-form-data |
| Cancellation | AbortController for request cancellation | best-practices-cancellation |
| Node.js Features | Proxy support, HTTP/2, environment configuration | best-practices-nodejs |
| 主题 | 描述 | 参考 |
|---|---|---|
| 表单数据 | multipart/form-data、URL编码表单、文件上传 | best-practices-form-data |
| 请求取消 | 使用AbortController取消请求 | best-practices-cancellation |
| Node.js特性 | 代理支持、HTTP/2、环境配置 | best-practices-nodejs |