node.js - Error: getaddrinfo ENOTFOUND in nodejs for get call -


I am running a web server on the node for which the code below

  var Restify = requires ('restify'); Var server = restify.createServer (); Var descendant = [[Author: 'Audrey Hepburn', lesson: "Nothing is impossible, the word itself says 'I am possible!'), {Author: 'Walt Disney', text:" You can not understand it then When this happens, but a kick in the teeth can be the best thing in the world for you "}, {author: 'unknown', lesson:" Even the biggest beginning was once. . "}, {Authors: 'Neil Donald Walsh', text:" You are afraid to die, and you are afraid to live. What is a way server.get ('/ quote / random', function (req, res) {var id = Math.floor (Math.random (*) * quotes.length); var q = quotes [id]; res.json (q);}); server.get ('/ quote /: id', function (req, Res) {if (quotes.length & lt; = req.params.id || req.params.id & lt; 0) {res.statusCode = 404; return res.send ('Error 404: no quotation found' );} var q = quote [req.params.id]; res.json (q);}); server.listen (process.env.port || 3011);   

And then I want to get a request in the following code

  var https = requirement ('' http ''); / ** * GET var optionsget = {host: 'http: // localhost ', Port: 3010, Path:' / Quotes / Random ', // How to do a HTTP call for the rest - GET * / // option if the URL is required with:' GET '// do GET}; Console.info (' Options Ready: '); console Info (optionsget); Console.info ('GET call'); // GET request var reqGet = https.request (optionsget, function) {console.log ("statusCode:", res.statusCode); // Header Details // console.log ("Header:", Res.headers); Res.on ('data', function (d) {console.info ('get results: \ n'); process.stdout.write (d); console.info ('\ n \ NCall full');} );}); ReqGet.end (); ReqGet.on ('Error', function (e) {console.error (e);});   

I'm just starting from the node and I do not even know that this is the right way. I want to test the performance of express and refresh I have done an Apache benchmark test for the server code that I wrote and found to contradict the result which is better. So I want to call remote services and then do some more later. Read mongodb to write. The code above is my starting point. I'm getting the error

  {[error: getaddrinfo ENOTFOUND] code: 'ENOTFOUND', errno: 'ENOTFOUND', syscall: 'getaddrinfo'}   

Getaddrinfo ENOTFOUND means the customer was not able to connect to the given address. Please try to specify the table without http:

  var optionsget = {host: 'localhost', ports: 3010, path: '/ quotation / random', // parameter without the rest of the URL Make the necessary method: 'GET' // do}; If you begin with learning resources, you will not be wrong and then go through some good books to get more knowledge - I suggest, but there are many people there.   / P>  

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -