Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wangjunzzz/api-gateway-httpx
修改httpx包
https://github.com/wangjunzzz/api-gateway-httpx
Last synced: about 2 months ago
JSON representation
修改httpx包
- Host: GitHub
- URL: https://github.com/wangjunzzz/api-gateway-httpx
- Owner: WangJunZzz
- Created: 2019-11-28T06:40:26.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-28T07:30:49.000Z (about 5 years ago)
- Last Synced: 2024-11-09T22:41:14.809Z (2 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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');
});
})();
```