# jimmy-common-http

> 通用HTTP方法

Latest version **1.0.1** (published 2020-08-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install jimmy-common-http
pnpm add jimmy-common-http
yarn add jimmy-common-http
bun add jimmy-common-http
```

## 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.1 |
| Published | 2020-08-04 |
| First published | 2020-08-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 130.4 KB |
| Known vulnerabilities | 0 (+25 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | wutongjiaojiajia |

## Links

- npm: https://www.npmjs.com/package/jimmy-common-http
- Repository: https://github.com/Wutongjiaojiajia/http
- Homepage: https://github.com/Wutongjiaojiajia/http#readme
- Issues: https://github.com/Wutongjiaojiajia/http/issues
- npm.io page: https://npm.io/package/jimmy-common-http

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^0.19.2

## Recent versions

- 1.0.1 (latest) — 2020-08-04
- 1.0.0 — 2020-08-04

## README

# common-http请求方法

### 安装方法

```bash
npm install jimmy-common-http
```

### http使用方法

```javascript
import http from 'common-http';
import env from './env';
import utils from '@/public/utils.js';

/**
 * url: 地址
 * method: 请求方法
 * params: 参数
 * timeout: 超时时间
 * isOriginalGET: 是否传统get传参
 */

// 接口错误提示
const errorCallback = (info) => {
    utils.failTip(info);
}

const req = ({ baseUrl, method, url, params, timeout, isOriginalGET}) => {
    let options={
        url: env[baseUrl] + url,
        method: method, 
        params: params, 
        timeout: timeout, 
        isOriginalGET: isOriginalGET,
        errorCallback:errorCallback
    };
    return http(options);
}

export default req;
```

### 参数说明

| 参数          | 说明                   | 类型     | 默认值 | 备注                                |
| :------------ | ---------------------- | -------- | ------ | ----------------------------------- |
| url           | (必填)api地址          | String   | -      | -                                   |
| method        | (必填)请求方法         | String   | -      | get/post/put/delete                 |
| params        | (必填)请求参数         | Object   | -      | -                                   |
| timeout       | 超时时间               | Number   | 20000  | -                                   |
| extraConfig   | 额外axios配置项        | Object   | -      | -                                   |
| isOriginalGET | 是否传统get传参        | Boolean  | false  | 使用url/?xxx=yyy的方法传参          |
| errorCallback | (必填)错误信息回调处理 | Function | -      | function(info) 回调提示显示info内容 |

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