Javascript 获得;ClientRequest的插座已挂起。<;匿名>&引用;使用节点获取调用GET请求时

Javascript 获得;ClientRequest的插座已挂起。<;匿名>&引用;使用节点获取调用GET请求时,javascript,node.js,jasmine,jasmine-node,node-fetch,Javascript,Node.js,Jasmine,Jasmine Node,Node Fetch,我使用节点获取模式和javascript来处理API请求。下面是我的代码(只是一个示例GET操作) 但是我得到了下面的错误。请帮我解决这个问题。我已经安装了节点获取、https代理模块 FetchError: request to http://postalpincode.in/api/pincode/600042 failed, reason: socket hang up at ClientRequest. (F:\johny\three projects\test-nodefetch\no

我使用节点获取模式和javascript来处理API请求。下面是我的代码(只是一个示例GET操作)

但是我得到了下面的错误。请帮我解决这个问题。我已经安装了节点获取、https代理模块

FetchError: request to http://postalpincode.in/api/pincode/600042 failed, reason: socket hang up
at ClientRequest. (F:\johny\three projects\test-nodefetch\node_modules\node-fetch\lib\index.js:1345:11)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at Socket.socketOnEnd (_http_client.js:423:9)
at emitNone (events.js:111:20)
at Socket.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
(node:19424) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:19424) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

您是否尝试过不使用代理-坦率地说,我看不出此代码中https代理的意义-以及在
http://10.10.104.4:50683
?顺便说一句,其余的代码无论如何都会失败-因为您的第一个代码不会返回任何内容-它是
.json()
而不是
.toJson()
在我的虚拟机中有一个代理,所以我使用该模式。如果没有proxt代理,我会得到以下错误节点testnoproxy.js(节点:10936)未处理PromisejectionWarning:FetchError:request to failed,原因:在ClientRequest连接ETIMEDOUT 184.168.224.180:80。看来您的代理是解决此问题的罪魁祸首?
FetchError: request to http://postalpincode.in/api/pincode/600042 failed, reason: socket hang up
at ClientRequest. (F:\johny\three projects\test-nodefetch\node_modules\node-fetch\lib\index.js:1345:11)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at Socket.socketOnEnd (_http_client.js:423:9)
at emitNone (events.js:111:20)
at Socket.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
(node:19424) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:19424) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.