Note that there are some explanatory texts on larger screens.

plurals
  1. POnodejs httprequest with data - getting error getaddrinfo ENOENT
    primarykey
    data
    text
    <h2>Update - Answered by self</h2> <p>I see one has to make sure that the DNS is resolved properly from the machine, check out <a href="https://nodejs.org/docs/latest/api/dns.html#dns_dns_resolve_hostname_rrtype_callback" rel="nofollow noreferrer">the node documentation</a> to make sure that domain is resolvable.</p> <h2>Original Question</h2> <p>i am writing a nodes based program,in which the user can ask me to do a httprequest on their behalf {off course they provide me with some data, and method to call with} but every time i do a httprequest it gives me an error </p> <p>getaddrinfo ENOENT this is how my code looks</p> <pre><code>function makehttprequest(deviceid, httpaction, httppath,methods, actiondata, callback) { console.log('we are here with httpaction' + httpaction + ' path ' + httppath + ' method ' + methods + ' action data ' + actiondata); //do the http post work, get the data, and call the callback function with return data var options = { host: httpaction, port: 80, path: httppath, method: methods }; try { var req = http.request(options, function(res) { console.log('STATUS: ' + res.statusCode); console.log('HEADERS: ' + JSON.stringify(res.headers)); res.setEncoding('utf8'); res.on('data', function (chunk) { console.log('BODY: ' + chunk); }); }); } catch(e) { console.log('error as : ' + e.message); } req.on('error', function(e) { console.log('problem with request: ' + e.message); }); // write data to request body console.log('writing data to request ..'); req.write(actiondata); console.log('finished writing data to request…'); req.end(); console.log('request ended…'); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload