@evo/fetch-io

中文文档
3.1.0发布于 2026/04/23ISCTypeScriptCommonJS近 30 天下载 3138

Service for fetching data.

原始使用文档
文档目录10 节
  1. usage
  2. init(myHost: string): void
  3. GET(url: string, params: Object, opts: Object): Response
  4. POST(url: string, params: Object, opts: Object): Response
  5. PUT(url: string, params: Object, opts: Object): Response
  6. DELETE(url: string, params: Object, opts: Object): Response
  7. my.GET(url: string, params: Object, opts: Object): Response
  8. my.POST(url: string, params: Object, opts: Object): Response
  9. my.PUT(url: string, params: Object, opts: Object): Response
  10. my.DELETE(url: string, params: Object, opts: Object): Respo…

fetch-io

Service for fetching data.

usage

import { GET, init } from '@evo/user-info';

const data = await GET('some/url');

API

Each api method implements Promise interface (can be awaited) and can throw 2 kind of exceptions FetchNetworkError and FetchDataError.

  • FetchNetworkError - is thrown when something is wrong with the network request.
  • FetchDataError is thrown when response has { status: 'error' }.

init(myHost: string): void

Initializes myHost for the service.

fetch-io depends on the user-info service so you need to initialize it also

The following API methods have the same signatures:

GET(url: string, params: Object, opts: Object): Response

POST(url: string, params: Object, opts: Object): Response

PUT(url: string, params: Object, opts: Object): Response

DELETE(url: string, params: Object, opts: Object): Response

Params:

  • url - url host
  • params - params that will be passed to fetch
  • opts - options passed to fetch call.

Executes GET request

Example

import { GET, POST } from '@evo/fetch-io';

const data = await GET('<url>');
const data = await POST('<url>', { param1: 'test' });
const data = await POST('<url>', { param1: 'test' }, { credentials: 'same-origin' });

The following API methods will use myHost as a host for the request:

my.GET(url: string, params: Object, opts: Object): Response

my.POST(url: string, params: Object, opts: Object): Response

my.PUT(url: string, params: Object, opts: Object): Response

my.DELETE(url: string, params: Object, opts: Object): Response

Example

import { my } from '@evo/fetch-io';

const data = await my.GET('<url>');
const data = await my.POST('<url>', { param1: 'test' });

版本与发布记录

@evo/fetch-io 共发布 14 个版本,首次发布于 2018/01/26;过去 12 个月发布了 3 个版本。

版本发布日期距今
3.1.0latest2026/04/236 个月前
3.0.22026/03/247 个月前
3.0.12026/03/068 个月前
3.0.02021/11/264 年前
2.3.12021/09/245 年前
2.3.02021/05/285 年前

关于 @evo/fetch-io 的常见问题

@evo/fetch-io 是什么?

Service for fetching data.

如何安装 @evo/fetch-io?

在项目目录运行 npm install @evo/fetch-io,或使用 pnpm add / yarn add / bun add。

@evo/fetch-io 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@evo/fetch-io 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@evo/fetch-io 可以商用吗?

@evo/fetch-io 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@evo/fetch-io 的下载量有多少?

根据 npm 官方下载统计,@evo/fetch-io 在 2026/10/14 – 2026/11/12 这 30 天内被下载 3,138 次,日均约 105 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@evo/fetch-io 还在维护吗?

最新版本 3.1.0 发布于 2026/04/23(6 个月前);至今共发布 14 个版本,其中过去 12 个月发布了 3 个;首次发布于 2018/01/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。