1.0.1 • Published 4 years ago

api-gateway-httpx v1.0.1

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

api-gateway-httpx

声明

为了适用Vue项目基于httpx做了一点修改。使用方式和httpx一致。 Httpx

Installation

$ npm install api-gateway-httpx --save

Usage

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

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.

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

  response.pipe(process.stdout);

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