@tick-core/http-client

0.0.9 • Public • Published

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

使用:@tick-core-zconf

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')

使用

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。

Readme

Keywords

none

Package Sidebar

Install

npm i @tick-core/http-client

Weekly Downloads

0

Version

0.0.9

License

ISC

Unpacked Size

16.8 kB

Total Files

12

Last publish

Collaborators

  • xiaodong.han