0.0.9 • Published 4 years ago
@tick-core/http-client v0.0.9
tick-core-http-client: http client
下载
npm install @tick-core/http-client
创建连接
const hostConfig = {
test: 'host:port'
}
const httpClient = new HttpClient(hostConfig)
const testClient = httpClient.getClient('test')
OR
import { Zconf, } from '@tick-core/zconf'
const zconf = new Zconf({ conf: { test: '/app/test', }, zookeeperConfs: { host: '127.0.0.1', port: 2181, }, })
const httpClient = new HttpClient(zconf) const testClient = httpClient.getClient('test')
## 使用
```lua
testClient.post({
url: '/test/12',
body: {
a: 12,
}
}).then(result => {
console.log(result)
}).catch(error => {
console.log(error)
})
testClient.get({
url: '/test/12',
qs: {
d: 15,
}
}).then(result => {
console.log(result)
}).catch(error => {
console.log(error)
})
参考:@blued-core/http-client,该client集成了qconf。