# request-func

> 基于 axios 库封装的请求工具

Latest version **1.0.0** (published 2021-03-02) · ISC license · 0 weekly downloads

## Install

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

## 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-03-02 |
| First published | 2021-03-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | zhongs |
| Maintainers | zhongs |
| Keywords | request |

## Links

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

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^0.21.1
- [@babel/polyfill](https://npm.io/package/@babel/polyfill.md) ^7.12.1

## Recent versions

- 1.0.0 (latest) — 2021-03-02

## README

Usage
---------------

安装
````javascript
npm install --save request-func
````

配置
````javascript
import request from 'request-func'

const userAPI = {
  getUser: `GET /api/users/userInfo`
};

// 或者

const gatherAPI = {
  allCvts: `GET /api/cvts`,
  getById: ({ id }) => `GET /api/task/${id}`,
  task: {
    create: "POST /api/task",
    getById: ({ id }) => `PUT /api/task/${id}`
  },
  summary: {
    create: "POST /api/meetingMinutes",
    update: ({ id }) => `PUT /api/meetingMinutes/${id}`,
  }
};

const apis = request(gatherAPI);

apis.allCvts({ params: {} }).then(res => {}).catch(err => {})

apis.task.getById({ id, params: {} }).then(res => {}).catch(err => {})

apis.task.create({ data: {} }).then(res => {}).catch(err => {})

apis.summary.update({ id }).then(res => {}).catch(err => {})
````

axios 全局设置 http://www.axios-js.com/zh-cn/docs/
````javascript
import request from 'request-func'
request.axiosConfigs = {
  headers: { "X-Requested-With": "XMLHttpRequest" }
};
````

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