@blued-core-oversea/undici-http-client
v0.2.1
Published
undici http client
Downloads
211
Readme
基于 undici 的一层封装。
http request client:
const httpClient = new RequestClient({
test: {
maxConnections: 100,
isQconf: true,
qconfHost: '/xxxxxx/xxxx/xxx',
},
})
// or
const httpClient = new RequestClient({
test: '/xxxxxx/xxxx/xxx', // qconf 地址
})
const testClient = () => httpClient.getClient('test')
async function main () {
const res = await testClient().get({
url: 'test/v1',
headersTimeout: 100,
})
console.log(res)
}
main()
支持的 API 列表
1. get(config: Config): Promise<any>
2. post(config: Config): Promise<any>
3. put(config: Config): Promise<any>
4. delete(config: Config): Promise<any>
5. getData(config: Config): Promise<any>
6. postData(config: Config): Promise<any>
7. putData(config: Config): Promise<any>
8. deleteData(config: Config): Promise<any>
9. getString(config: Config): Promise<string>
10. postString(config: Config): Promise<string>
11. putString(config: Config): Promise<string>
12. deleteString(config: Config): Promise<string>
13. do(config: Config, method: undici.Dispatcher.HttpMethod): Promise<undici.Dispatcher.ResponseData>
14. doWithoutStatusCodeException(config: Config, method: undici.Dispatcher.HttpMethod): Promise<undici.Dispatcher.ResponseData>