Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wangjunzzz/api-gateway-httpx

修改httpx包
https://github.com/wangjunzzz/api-gateway-httpx

Last synced: about 2 months ago
JSON representation

修改httpx包

Awesome Lists containing this project

README

        

api-gateway-httpx
===========

## 声明
为了适用Vue项目基于httpx做了一点修改。使用方式和httpx一致。
[Httpx](https://github.com/JacksonTian/httpx)
## Installation

```bash
$ npm install api-gateway-httpx --save
```

## Usage

```js
'use strict';

const httpx = require('api-gateway-httpx');

httpx.request('http://www.baidu.com/').then((response) => {
response.pipe(process.stdout);

response.on('end', () => {
process.stdout.write('\n');
});
}, (err) => {
// on error
});
```

Or with `co`.

```js
co(function* () {
var response = yield httpx.request('http://www.baidu.com/');

response.pipe(process.stdout);

response.on('end', () => {
process.stdout.write('\n');
});
});
```

Or with `async/await`.

```js
(async function () {
var response = await httpx.request('http://www.baidu.com/');

response.pipe(process.stdout);

response.on('end', () => {
process.stdout.write('\n');
});
})();
```