I am trying call multiple API in request but getting below exception when I am running the application.
Node Version: 10.15.2 NPM Version: 6.4.1
I already set proxy at global level using npm config set http-proxy in the terminal
Exception:
C:\Data\NPM\Testing>node server.js
node.js application starting...
Node HTTP server is listening
One
two
{ Error: getaddrinfo ENOTFOUND mocktarget.apigee.net mocktarget.apigee.net:80
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
errno: 'ENOTFOUND',
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'mocktarget.apigee.net',
host: 'mocktarget.apigee.net',
port: 80 }
{ Error: getaddrinfo ENOTFOUND httpbin.org httpbin.org:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
errno: 'ENOTFOUND',
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'httpbin.org',
host: 'httpbin.org',
port: 443 }
Code:
var http = require('http');
var async = require('async');
var request = require('request');
console.log('node.js application starting...');
var svr = http.createServer(function (req, resp) {
async.parallel({
one: function (callback) {
console.log("One");
request('http://mocktarget.apigee.net/json', function (error, response, body) {
console.log(error);
});
},
two: function (callback) {
console.log("two");
request('https://httpbin.org/headers', function (error, response, body) {
console.log(error);
});
}
}, function (err, results) {
console.log(results);
});
});
svr.listen(9000, function () {
console.log('Node HTTP server is listening');
});
Please help me how to resolve this issue if anyone knows. Thank you.