0.2.3-alpha.0 • Published 1 year ago
@ukb/request v0.2.3-alpha.0
ukb-request
安装
npm i ukb-request -S
使用
import { createRequest, createInterceptor } from 'ukb-request'
export const request = createRequest({
baseUrl: '',
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded',
},
requestInterceptor: [
(request) => {
request.header['content-type'] = 'application/x-www-form-urlencoded'
return request
},
],
responseInterceptor: [
createInterceptor((response) => {
response.data
}),
],
})
request({
url: '',
})
request.post({
url: '',
})
request.get({
url: '',
})
二次继承
用于部分模板具有特殊性处理,但是拦截器相关操作也想要 通过 create 方法,将所有属性进行合并
拦截器合并遵循 先执行父类拦截器后执行子类拦截器
const extendsRequest = request.create({
baseUrl: '',
requestInterceptor: [
(request) => {
request.header['content-type'] = 'application/x-www-form-urlencoded'
return request
},
],
})
0.2.3-alpha.0
1 year ago
0.2.2-alpha.0
1 year ago
0.2.1-alpha.0
1 year ago
0.1.15-alpha.0
1 year ago
0.1.10-alpha.0
1 year ago
0.1.9-alpha.0
1 year ago
0.1.14-alpha.0
1 year ago
0.1.11-alpha.0
1 year ago
0.1.8-alpha.0
1 year ago
0.1.13-alpha.0
1 year ago
0.1.12-alpha.0
1 year ago
0.1.6-alpha.0
1 year ago
0.1.7-alpha.0
1 year ago
0.1.3-alpha.0
2 years ago