# u-axios

> 封装的uni.request 模仿axios并实现了一部分功能

Latest version **0.0.4** (published 2021-03-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install u-axios
pnpm add u-axios
yarn add u-axios
bun add u-axios
```

## 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.4 |
| Published | 2021-03-31 |
| First published | 2021-03-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | 李美超 |
| Maintainers | li_mei_chao |
| Keywords | uni-app, request |

## Links

- npm: https://www.npmjs.com/package/u-axios
- npm.io page: https://npm.io/package/u-axios

## Recent versions

- 0.0.4 (latest) — 2021-03-31
- 0.0.3 — 2021-03-31
- 0.0.2 — 2021-03-31
- 0.0.1 — 2021-03-31

## README

##  使用方法

```javascript
import { BASE_URL } from "./config";

import Request from "./request/index";
const request = new Request();

const instance = request.create({
  baseURL: BASE_URL,
  timeout: 5000
});

instance.interceptors.request.use(config => {
  console.log(config);
  config.method = "post";
  return config;
});
instance.interceptors.response.use(
  res => {
    return res.data;
  },
  err => {
    return err;
  }
);
export default instance;

```

```javascript
import request from "@/utils/request.js";

function demo(data) {
  return request({
    url: "/",
    header: { token: "token" },
    abortSame: false,//判断是否需要中断上一个相同url相同method的连接
    data: data,//无论是get还是post  都是data  这里和axios不一样
    method: "post"
  });
}

demo(data).then(res=>{
..........执行一些方法
}).catch(err=>{
..........执行一些方法    
})
```

##  一般还需第二层封装,自己按需求来

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