I'm trying to return boolean answer from function and want to check with if-else statements.
function dnsCheck(domain,tld) {
var dns = require('dns')
dns.lookup(domain+'.'+tld, function (err, addresses) {
if (err) return false // means domain not registered
else return true // means domain registered
})
}
my conditional statement:
if(domain_validator(domain,tld) && dnsCheck(domain,tld)) {
res.end("avl")
}
else {
res.end("not avl")
}
The first function alone works in the if statement but when I add 2nd function "dnsCheck", it fails to work as expected. Am I missing something?