1.1.0 • Published 5 years ago

network-request-proxy v1.1.0

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

network-request-proxy

Designed so that all network requests could be forwarded through Charles Proxy (or similar proxy service).

Installation

npm i network-request-proxy

Usage

At the very top of your entry file

 require("network-request-proxy")("http://127.0.0.1:8888");
 .......

Quick Examples

Basic

Each of the following calls will be shown in Charles Proxy (or other proxy tool).

require("network-request-proxy")("http://127.0.0.1:8888");

const axios = require("axios"),
      qs = require('qs');

axios.get("http://some/url/")
     .then(res => console.log(res.data))
     .catch(e => console.error(e));

axios.get("https://some/url/")
     .then(res => console.log(res.data))
     .catch(e => console.error(e));

axios.post("https://some/url", qs.stringify({ 'bar': 123 }))
     .then(res => console.log(res.data))
     .catch(e => console.error(e));

alt text

Debugging

If you want to log the requests that get sent out as well as proxy them you can set the cli enviroment variable DEBUG=network-request-proxy and this will log all requests that are sent.

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago