# moleio

> Promise based HTTP client for browser and node.js

Latest version **0.0.2** (published 2021-12-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install moleio
pnpm add moleio
yarn add moleio
bun add moleio
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2021-12-20 |
| First published | 2021-12-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 23.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | tyson |
| Maintainers | flyingcow |
| Keywords | HTTP |

## Links

- npm: https://www.npmjs.com/package/moleio
- Repository: https://github.com/tysonwang/moleio
- Homepage: https://github.com/tysonwang/moleio#readme
- Issues: https://github.com/tysonwang/moleio/issues
- npm.io page: https://npm.io/package/moleio

## Dependencies (1)

- [qs](https://npm.io/package/qs.md) ^6.9.6

## Recent versions

- 0.0.2 (latest) — 2021-12-20
- 0.0.1 — 2021-12-20
- 1.0.8 — 2021-12-20

## README

# moleio
Promise based HTTP client for the browser ,wx,my,and node.js
## 功能描述
类似于 axios 库，提供除浏览器端 ajax 请求外，该库提供了 node 端,微信小程序，uniapp,taro,支付宝小程序，飞书的异步请求的支持
## 使用方式
```js
const mole = require('moleio');
mole.uploadConfig((config)=>{return config})  // 上传的配置
mole.interceptors.request.use(()=>{}) // 请求的配置
mole.interceptors.response.use((success)=>{},(err)=>{}) // 响应的配置
// 使用默认实例
mole.request(url,[data,[options]]);
mole.get({url,data,[options]});
mole.post({url,data,[options]});
mole.put({url,data,[options]});
mole.delete({url,data,[options]});
mole.cancel(url|| conf)   // 根据条件取消请求
mole.lock(url|| conf)   // 根据条件临时锁定请求
mole.unlock(url|| conf)   // 根据条件解锁请求
mole.start();  // 开启请求
mole.stop();   // 停止请求
conf = {
        ignore:(url)=>{
                return true||false
        },
        match:(url)=>{
               return []
        }
}

mole.race()
mole.all()
mole.spread()
mole.settled() 
```
```js
// 创建实例的两种方式
const mole = new mole(engine); // 创建新的实例 默认不传入参数为浏览器端使用，传入 node,wx,my,taro ...可更换请求环境
const mole = mole.create(engine); // 创建新的实例对象 默认不传入参数为浏览器端使用，传入 node,wx,my,taro ...可更换请求环境
```
## 返回值类型
```js
// 成功
response = {
        header,
        data,
        status,
        config
}
// err
error = {
        header,
        msg,
        status,
        config
}
```

```js
// 当满足某种状态下 结束所有后续的请求 ，比如接口授权过期401状态，当某一个接口401后，后续的请求自动作废

```

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