使用像fiddler一样的提取API的代理

如何使用Fetch API设置代理 我正在开发一个node.js应用程序,我想看看HTTPS响应的响应正文。 我正在使用这个使用节点http的npm包里面: https : //www.npmjs.com/package/isomorphic-fetch

我试图设置envvariables,如:

set https_proxy=http://127.0.0.1:8888 set http_proxy=http://127.0.0.1:8888 set NODE_TLS_REJECT_UNAUTHORIZED=0 

但它似乎只适用于请求NPM节点模块。

我总是得到以下消息:

 http://127.0.0.1:8888 (node:30044) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): FetchError: request to https://www.index.hu failed, reason: read ECONNRESET 

@ jimliang 发布了一个node-fetch的解决scheme 。 他

使用https://github.com/TooTallNate/node-https-proxy-agent

 fetch('https://www.google.com',{ agent:new HttpsProxyAgent('http://127.0.0.1:8580')}) .then(function(res){ //... })