# @alicloud/fetcher-fetch

> @alicloud/fetcher 的底层 fetch 实现，可独立使用

Latest version **1.6.11** (published 2023-03-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @alicloud/fetcher-fetch
pnpm add @alicloud/fetcher-fetch
yarn add @alicloud/fetcher-fetch
bun add @alicloud/fetcher-fetch
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.6.11 |
| Published | 2023-03-24 |
| First published | 2020-12-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 13.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 54 |
| Author | Jianchun Wang |
| Maintainers | jacksontian, fengmk2, pagecao, aliyunsdkteam, console-fe |
| Keywords | fetcher, fetch |

## Links

- npm: https://www.npmjs.com/package/@alicloud/fetcher-fetch
- Repository: https://github.com/aliyun/alibabacloud-console-base
- Homepage: https://github.com/aliyun/alibabacloud-console-base/tree/master/packages-fetcher/fetcher-fetch
- Issues: https://github.com/aliyun/alibabacloud-console-base/issues
- npm.io page: https://npm.io/package/@alicloud/fetcher-fetch

## Dependencies (2)

- [unfetch](https://npm.io/package/unfetch.md) ^4.2.0
- [@alicloud/sandbox-escape](https://npm.io/package/@alicloud/sandbox-escape.md) ^1.1.8

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.6.11 (latest) — 2023-03-24
- 1.3.2-alpha.0 (alpha) — 2022-06-14
- 1.6.10 — 2023-01-19
- 1.6.9 — 2023-01-05
- 1.6.8 — 2023-01-05
- 1.6.7 — 2023-01-05
- 1.6.6 — 2022-11-08
- 1.6.4 — 2022-11-08
- 1.6.2 — 2022-10-12
- 1.6.0 — 2022-08-18
- 1.5.3 — 2022-08-17
- 1.5.2 — 2022-08-16
- 1.5.1 — 2022-08-16
- 1.5.0 — 2022-07-22
- 1.4.1 — 2022-07-05
- … 110 more at https://npm.io/package/@alicloud/fetcher-fetch/versions

## README

# @alicloud/fetcher-fetch

> `@alicloud/fetcher` 的底层 [fetch]，可以单独使用。几乎原生的 `fetch`，除了：
>
> 1. 添加 timeout（原生 [fetch] 不支持超时）
> 2. 没有 fetch 的情况下使用 [unfetch]，它非常轻量，不做全局性 polyfill，应用有需要的话，可以自行引入 [whatwg-fetch]

## INSTALL

```shell
tnpm i @alicloud/fetcher-fetch -S
```

## APIs

```typescript
import fetch, {
  EFetchError,
  FetchOptions
} from '@alicloud/fetcher-fetch';

fetch(url, {
  timeout: 20000, // 超时毫秒数，默认无，保持跟原生一致
  method,
  ...
}).then(response => response.json());
```

## throws

抛错 `error.name` 说明：

* AbortError - 原生
* EFetchTimeout - 超时（前端模拟）
* EFetchNetwork - 网络错误，如浏览器刷新（未到业务层）

[fetch]: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
[unfetch]: https://github.com/developit/unfetch
[whatwg-fetch]: https://github.com/github/fetch

---
_Source: https://npm.io/package/@alicloud/fetcher-fetch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
