Callback and dns.reverse function

18 views
Skip to first unread message

Zakaria M

unread,
Feb 9, 2018, 2:15:24 AM2/9/18
to nodejs
Hi All and sorry for my english.
i have a function that return a dns name off an IP on console.log but my goal is to have it as variable (to push it on a page later).
My function :
function toto(ip){
    const dns = require('dns');
 
    dns.reverse(ip, function(err, domains) {
      dns.setServers(['10.1.5.4', '10.15.5.2']);
      if (domains) {
        console.log(JSON.stringify(domains)); 
      } else {
        callback(err.code);
      }
 
 
    });
 
};
 
toto('10.16.4.16');
On console i have :  ["sertest"]

----
PS : can i have this  var tata=toto('10.16.4.16'); ?

Reply all
Reply to author
Forward
0 new messages