# acp-request

> 基于umi-request的请求库

Latest version **1.0.0** (published 2021-11-13) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-11-13 |
| First published | 2021-11-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 37.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | WuHan |
| Maintainers | wu_han |
| Keywords | cp-request |

## Links

- npm: https://www.npmjs.com/package/acp-request
- npm.io page: https://npm.io/package/acp-request

## Dependencies (7)

- [md5](https://npm.io/package/md5.md) ^2.3.0
- [core-js](https://npm.io/package/core-js.md) 3
- [toastify-js](https://npm.io/package/toastify-js.md) ^1.9.3
- [umi-request](https://npm.io/package/umi-request.md) ^1.3.5
- [query-string](https://npm.io/package/query-string.md) 5
- [@bj-nsc/functions](https://npm.io/package/@bj-nsc/functions.md) ^1.2.20
- [@babel/runtime-corejs3](https://npm.io/package/@babel/runtime-corejs3.md) ^7.12.5

## Recent versions

- 1.0.0 (latest) — 2021-11-13

## README

### nsc-request

基于 umi-request 的请求库; 统一处理防篡改; 统一处理请求错误逻辑

### 安装

```javascript
// 安装
npm install nsc-request --save;
//或者
yarn add nsc-request;

// 导入
import request from "nsc-request";
```

### 示例

```javascript
import request from "nsc-request";

// GET请求不带参数
export const fetchCaptchaType = () => {
  return request(`/api/serviceName/busiName/test`);
};

// GET请求带参数
export const fetchCaptchaType = (params) => {
  return request(`/api/serviceName/busiName/test`, { params });
};

// post请求
export const fetchCaptchaType = (data) => {
  return request.post(`/api/serviceName/busiName/test`, { data });
};

// post请求自定义请求头和需要加密的参数
export const fetchCaptchaType = (data) => {
  return request.post(`/api/serviceName/busiName/test`, {
    data,
    headers: { Authorization: "xxxx" },
    // 将需要加密的字段以数组形式配置, 如果所有参数都需要加密传"all", 如果不需要加密则不需要配置encryptFields
    // 嵌套对象加密使用.分隔符路径
    encryptFields: ["username", "password", "person.user.pwd"],
  });
};
```

如果需要自定义全局错误处理逻辑请使用`extendOptions`函数，`request.extendOptions(config对象)`
所有 API 与`umi-request`一致，具体用法请参考[官方文档](https://github.com/umijs/umi-request/blob/master/README_zh-CN.md)

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