title: Node.js - How do you call an async function with a callback?
body: <p>The async function below is supposed to check if a url is a legit url</p>
  
  <pre><code>let CheckUrl = function (url, done) {
    dns.lookup(url, function(err, address) { 
      if (err) return done(err);
      done(null, true); //return true because I don't care what the address is, only that it works
    });
  } 
  </code></pre>
  
  <p>The express.js code below gets the url but I'm having trouble understanding how to write the if statement so that it returns true or false.  </p>
  
  <pre><code>// Gets URL 
  app.post("/api/shorturl/new", function(req, res) {
    if (CheckUrl(req.body.url)) {
      // do something
    }
  });
  </code></pre>
  
  <p>I'm not sure what to pass as the second argument in CheckUrl() in this if statement. Or maybe I wrote the first async function incorrectly to begin with?</p>