# @vtils/node-request

> 基于 axios 封装的 node.js 网络请求库。

Latest version **2.59.0** (published 2020-05-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install @vtils/node-request
pnpm add @vtils/node-request
yarn add @vtils/node-request
bun add @vtils/node-request
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.59.0 |
| Published | 2020-05-13 |
| First published | 2019-10-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 19.8 KB |
| Known vulnerabilities | 0 (+26 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 253 |
| Author | Jay Fong |
| Maintainers | funch |
| Keywords | node, http, https, request, axios |

## Links

- npm: https://www.npmjs.com/package/@vtils/node-request
- Repository: https://github.com/fjc0k/vtils
- Homepage: https://github.com/fjc0k/vtils/tree/master/packages/node-request
- Issues: https://github.com/fjc0k/vtils/issues
- npm.io page: https://npm.io/package/@vtils/node-request

## Dependencies (7)

- [axios](https://npm.io/package/axios.md) ^0.19.0
- [form-data](https://npm.io/package/form-data.md) ^2.5.1
- [iconv-lite](https://npm.io/package/iconv-lite.md) ^0.5.0
- [mime-types](https://npm.io/package/mime-types.md) ^2.1.24
- [tough-cookie](https://npm.io/package/tough-cookie.md) ^3.0.1
- [axios-cookiejar-support](https://npm.io/package/axios-cookiejar-support.md) ^0.5.0
- [tough-cookie-redisstore](https://npm.io/package/tough-cookie-redisstore.md) ^0.0.4

## 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

- 2.59.0 (latest) — 2020-05-13
- 2.58.0 — 2020-04-30
- 2.57.0 — 2020-01-19
- 2.56.0 — 2020-01-15
- 2.55.0 — 2019-11-25
- 2.54.0 — 2019-11-19
- 2.52.0 — 2019-11-01
- 2.51.1 — 2019-11-01
- 2.51.0 — 2019-11-01
- 2.50.0 — 2019-11-01
- 2.49.0 — 2019-11-01
- 2.48.0 — 2019-10-31

## README

# @vtils/node-request

基于 axios 封装的 node.js 网络请求库。

## 特性

- 仅支持 `GET`、`POST` 请求方式
- 内置 cookie jar 支持
- 内置更易用的文件上传支持
- 更易用的数据提交方式

## 安装

```bash
# yarn
yarn add vtils @vtils/node-request

# or, npm
npm i vtils @vtils/node-request --save
```

## 使用

```ts
import { NodeRequest } from 'node-request'

const nr = new NodeRequest({
  baseUrl: 'https://foo.bar/api',
  cookieJar: {
    enabled: true,
  },
  timeout: 6000,
})

async function getUserInfo(userId: number) {
  return nr.request<{ id: number, name: string, avatar: string }>({
    url: '/getUserInfo',
    method: 'POST',
    jsonData: { id: userId },
  }).then(res => res.data)
}

async function updateUserAvatar(userId: number, avatarPath: string) {
  return nr.request({
    url: '/updateUserAvatar',
    method: 'POST',
    formData: { id: userId },
    fileData: { avatar: avatarPath },
  }).then(res => res.data)
}
```

## 许可

MIT ©️ Jay Fong

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