# @lgd-utils/axios

> A axios adapter and middleware tool

Latest version **0.0.6** (published 2022-01-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @lgd-utils/axios
pnpm add @lgd-utils/axios
yarn add @lgd-utils/axios
bun add @lgd-utils/axios
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2022-01-10 |
| First published | 2021-10-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 9 |
| Unpacked size | 529.8 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 16 |
| Author | LGD.HuaFEEng |
| Maintainers | lgd.huafeeng |
| Keywords | axios, http, request, response, middleware, adapter, cache |

## Links

- npm: https://www.npmjs.com/package/@lgd-utils/axios
- Repository: https://github.com/LGDHuaOPER/lgd-utils
- Homepage: https://github.com/LGDHuaOPER/lgd-utils/tree/main/packages/axios#readme
- Issues: https://github.com/LGDHuaOPER/lgd-utils/issues
- npm.io page: https://npm.io/package/@lgd-utils/axios

## Dependencies (9)

- [qs](https://npm.io/package/qs.md) ^6.10.1
- [axios](https://npm.io/package/axios.md) ^0.23.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [lru-cache](https://npm.io/package/lru-cache.md) ^6.0.0
- [@lgd-utils/array](https://npm.io/package/@lgd-utils/array.md) ^0.0.14
- [@lgd-utils/utils](https://npm.io/package/@lgd-utils/utils.md) ^0.0.16
- [@lgd-utils/object](https://npm.io/package/@lgd-utils/object.md) ^0.0.14
- [@lgd-utils/symbol](https://npm.io/package/@lgd-utils/symbol.md) ^0.0.1
- [@lgd-utils/validate](https://npm.io/package/@lgd-utils/validate.md) ^0.0.17

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

- 0.0.6 (latest) — 2022-01-10
- 0.0.5 — 2021-11-22
- 0.0.4 — 2021-11-19
- 0.0.3 — 2021-10-29
- 0.0.2 — 2021-10-28
- 0.0.1 — 2021-10-21

## README

<!--
 * @Author: shiconghua
 * @Alias: LGD.HuaFEEng
 * @Date: 2021-09-10 20:12:33
 * @LastEditTime: 2021-12-30 17:58:54
 * @LastEditors: shiconghua
 * @Description: file content
 * @FilePath: /lgd-utils/packages/axios/README.md
-->
# `@lgd-utils/axios`

<div align="center">

[![Bundle size](https://img.shields.io/bundlephobia/minzip/@lgd-utils/axios.svg)](https://bundlephobia.com/result?p=@lgd-utils/axios)
[![MIT](https://img.shields.io/badge/license-MIT-000000.svg)](https://opensource.org/licenses/MIT/)
[![NPM downloads](https://img.shields.io/npm/dm/@lgd-utils/axios.svg?style=flat)](https://npmjs.org/package/@lgd-utils/axios)
[![NPM version](https://img.shields.io/npm/v/@lgd-utils/axios.svg?style=flat)](https://npmjs.org/package/@lgd-utils/axios)
[![lodash](https://img.shields.io/badge/lodash-4-green.svg)](https://github.com/lodash/lodash)
[![npm](https://img.shields.io/npm/dt/@lgd-utils/axios)](https://www.npmjs.com/package/@lgd-utils/axios)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)

</div>

> A axios adapter and middleware tool

## Usage

```
import axios from 'axios';
import { adapterCacheWrapper } from '@lgd-utils/axios';

const http = axios.create({
	baseURL: '/',
	// cache will be enabled by default when http method is get
	adapter: adapterCacheWrapper(axios.defaults.adapter)
});

http.get('/api/userInfo'); // make real http request
http.get('/api/userInfo'); // use the response from the cache of previous request, without real http request made
http.get('/api/userInfo', { forceUpdateCache: true }); // will forceUpdate the cache and the the real http request invoked
http.get('/api/userInfo', { disableCache: true }); // disable cache manually and the the real http request invoked
```

#### 注意
- 如果使用 dist/axios.global.prod.js，需要先引入 axios 和 qs
```
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://cdn.bootcss.com/qs/6.10.1/qs.min.js"></script> 或
<script src="https://cdn.bootcdn.net/ajax/libs/qs/6.10.1/qs.js"></script>
```

## Contribute

- [LGD.HuaFEEng(LGD.HuaOPER)][blog]

## Documentation

- [Quick tutorial](https://github.com/LGDHuaOPER/lgd-utils/tree/main/packages/axios#readme)
- [Issue](https://github.com/LGDHuaOPER/lgd-utils/issues)

## Related

- [@lgd-utils/array](https://github.com/LGDHuaOPER/lgd-utils/tree/main/packages/array) - A front-end array tool
- [@lgd-utils/cached-storage](https://github.com/LGDHuaOPER/lgd-utils/tree/main/packages/cached-storage) - 一个具有失效功能的缓存存储库
- [@lgd-utils/collection](https://github.com/LGDHuaOPER/lgd-utils/tree/main/packages/collection) - A front-end collection tool
- [@lgd-utils/error](https://github.com/LGDHuaOPER/lgd-utils/tree/main/packages/error) - A front-end error tool
- [@lgd-utils/html](https://github.com/LGDHuaOPER/lgd-utils/tree/main/packages/html) - A front-end html tool
- [@lgd-utils/number](https://github.com/LGDHuaOPER/lgd-utils/tree/main/packages/number) - A front-end number tool
- [@lgd-utils/object](https://github.com/LGDHuaOPER/lgd-utils/tree/main/packages/object) - A front-end object tool
- [@lgd-utils/polling](https://github.com/LGDHuaOPER/lgd-utils/tree/main/packages/polling) - A front-end polling tool
- [@lgd-utils/regexp](https://github.com/LGDHuaOPER/lgd-utils/tree/main/packages/regexp) - A front-end regexp tool
- [@lgd-utils/request-queue](https://github.com/LGDHuaOPER/lgd-utils/tree/main/packages/request-queue) - A front-end request-queue tool
- [@lgd-utils/screenlog](https://github.com/LGDHuaOPER/lgd-utils/tree/main/packages/screenlog) - Bring console.log and so on, on the screen
- [@lgd-utils/symbol](https://github.com/LGDHuaOPER/lgd-utils/tree/main/packages/symbol) - A front-end symbol tool
- [@lgd-utils/utils](https://github.com/LGDHuaOPER/lgd-utils/tree/main/packages/utils) - A front-end utils tool
- [@lgd-utils/validate](https://github.com/LGDHuaOPER/lgd-utils/tree/main/packages/validate) - A front-end verification tool
- [More…](https://github.com/LGDHuaOPER/lgd-utils)

[blog]: https://lgdhuaoper.github.io/ '敬昭的博客'

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