1.0.9 • Published 4 months ago
@monsterooo/http v1.0.9
title: Http 数据请求 sidemenu: false nav: title: 数据请求 path: /http
order: 3
Http
基于 axios
二次封装的 Http 类。
代码演示
import createHttp from '@monsterooo/http';
const http = createHttp({
domain: 'http://api.thunderfost.com',
});
const adminHttp = createHttp({
domain: 'http://api.admin.thunderfost.com',
});
const request = adminHttp();
createHttp
API
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
domain | 请求域 | string | - |
isSuccess | 判断数据是否请求成功 | (data) => boolean | - |
http
参数 | 说明 | 类型 | 默认值 | |
---|---|---|---|---|
domain | 请求域 | string | - | |
url | 请求地址,可以为全路径 | string | - | |
method | 请求方式 | string | get | |
data | 请求参数 | any | - | |
filterEmptyParam | 是否过滤为空的参数 | boolean | true | |
onUnauthorized | session 失效回调 | function | - | |
...others | 参考 axios | - | - |