I am using node-fetch modeule along with javascript to work with API requests. Below is my code (just a sample GET operation)
var fetch = require('node-fetch');
var https = require('https');
const HttpsProxyAgent = require('https-proxy-agent');
But I m getting the below error. Please help me resolving this
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.
I am using node-fetch modeule along with javascript to work with API requests. Below is my code (just a sample GET operation) var fetch = require('node-fetch'); var https = require('https'); const HttpsProxyAgent = require('https-proxy-agent');
fetch('http://postalpincode.in/api/pincode/600042', {method: 'GET', agent: new HttpsProxyAgent('http://10.10.104.4:50683') }) .then(resRaw=>{ resRaw.toJson(); }) .then(resJson=>{ console.log(resJson); })
But I m getting the below error. Please help me resolving this
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.