3.1.0 • Published 3 years ago
@blued-core/http-client v3.1.0
基于 request 的一层封装。
npm i @blued-core/http-clientcache 与 qconf-conf 组件都为可选的,可以自己根据描述自定义
使用方式:
import HttpClient from '@blued-core/http-client'
import Cache from '@blued-core/cache'
import { QconfHost } from '@blued-core/qconf-conf'
const qconfConf = new QconfHost({
host1: 'XXX'
})
// Cache 可以使用 Map 代替
const httpClient = new HttpClient(qconfConf, new Cache())
const httpClient1 = httpClient.getClient('host1')
async function main () {
const res = await httpClient1.getData({
url: 'path1/path2',
qs: { id: 1 }
})
console.log(res)
}
main()API
调用参数与request参数一致,提供如下八个方法:
基于method抽出来的四个方法:get、post、put、delete。
基于以上四个方法的基础上处理返回值的四个方法:getData、postData、putData、deleteData。
两者的区别
httpClient.get({
url: 'XXX'
}) // => { code: 200, data: 'Hello World' }
httpClient.getData({
url: 'XXX'
}) // => 'Hello World'3.1.0
3 years ago
3.0.9
3 years ago
3.0.8
4 years ago
3.0.7
4 years ago
3.0.6
4 years ago
3.0.4
5 years ago
3.0.5
5 years ago
3.0.3
5 years ago
3.0.2
5 years ago
3.0.1
5 years ago
3.0.0
5 years ago
2.1.3
5 years ago
2.0.3
5 years ago
2.0.2
6 years ago
2.0.1
6 years ago
2.0.0
6 years ago
1.1.0
6 years ago
1.0.9
6 years ago
1.0.8
7 years ago
1.0.7
7 years ago
1.0.6
7 years ago
1.0.5
7 years ago
1.0.4
7 years ago
1.0.3
7 years ago
1.0.2
7 years ago
1.0.1
7 years ago
1.0.0
7 years ago