# better-request

> node http request client

Latest version **3.0.1** (published 2020-07-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install better-request
pnpm add better-request
yarn add better-request
bun add better-request
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2020-07-16 |
| First published | 2019-12-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 47.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | zcs |
| Maintainers | bjzhangchengsi |
| Keywords | frontend, node.js, node, httpclient, request, typescript |

## Links

- npm: https://www.npmjs.com/package/better-request
- Repository: https://github.com/zcs19871221/better-request
- Homepage: https://github.com/zcs19871221/better-request#readme
- Issues: https://github.com/zcs19871221/better-request/issues
- npm.io page: https://npm.io/package/better-request

## Dependencies (2)

- [iconv-lite](https://npm.io/package/iconv-lite.md) ^0.5.1
- [@types/node](https://npm.io/package/@types/node.md) ^13.13.10

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 3.0.1 (latest) — 2020-07-16
- 3.0.0 — 2020-06-08
- 2.0.8 — 2020-05-15
- 2.0.7 — 2020-04-29
- 2.0.6 — 2020-04-28
- 2.0.5 — 2020-04-28
- 2.0.4 — 2020-03-04
- 2.0.3 — 2020-02-29
- 2.0.1 — 2020-02-29
- 2.0.0 — 2020-02-29
- 1.0.2 — 2019-12-18
- 1.0.1 — 2019-12-18
- 1.0.0 — 2019-12-18

## README

# 特性

1. 失败重试
2. 无callBack,全promise
3. 支持pipe
4. 根据请求content-type自动处理请求体
5. 传入关键词|自定义函数实现对返回体的流式处理
6. 通过配置处理redirect
7. 通过配置statusCode筛选
8.  纯typescript编写
9.  单元测试覆盖80%

# 安装
npm install better-request

# 使用

    import Request from 'better-request'

    // 静态方法
    const body = 'string'|new Buffer()|readStream;
    Request.fetch({url:'http://xxx.xx.com',method:'GET'}, body).then().catch()
    Request.fetchThenPipe({url:'http://xxx.xx.com',method:'GET'}, body, fs.createWriteStream(filePath)).then().catch()

    // 实例对象
    const request = new Request({url:'http://xxx.xx.com',method:'GET'})
    request.fetch(...同上)
    request.fetchThenPipe(...同上)

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