Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
260 views
in Technique[技术] by (71.8m points)

node.js - how to check dns in nodejs javascript

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...