I am trying to check valid domain name in javascript, I have given the code below which I have tried. For a valid domain, it's showing a correct message if I give an invalid domain name it's throwing an error.
var w3 = dns.lookup(event.domain_name, function (err, response, family) {
console.log("aaaa",response)
if(err){
callback({
status : false,
message : "Connection Failure",
data : "Contact Administrator"
})
}
if(!response){
callback( {
status : false,
message : "InValid DNS",
data : []
})
}
else{
callback(null,{
status : true,
message : "Valid DNS",
data : response
})
}
//below is my error which I am getting when I pass the invalid domain name
{"errorType":"Error","errorMessage":"[object Object]","stack":["Error: [object Object]"," at _homogeneousError (/var/runtime/CallbackContext.js:12:12)"," at postError (/var/runtime/CallbackContext.js:29:54)"," at callback (/var/runtime/CallbackContext.js:41:7)"," at /var/runtime/CallbackContext.js:104:16"," at GetAddrInfoReqWrap.callback (/var/task/main.js:23:29)"," at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:17)"]}
question from:
https://stackoverflow.com/questions/66045350/how-to-check-dns-in-nodejs-javascript 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…