title: pending or undefined inside a promise
body: <p>I have a module for nodejs where i search mx records of email service, then i call a reduce to find the one with lowest priority (i will connect to this mx record to send a message) and then i need to save this value (exactly smtp.gmail.com) and pass it into my another module. What do i do wrong ?</p>
  <pre><code>const dns = require('dns');
  
  async function getMX() {
  return new Promise(function (resolve, reject) {
      dns.resolveMx('gmail.com', function (err, addresses) {
          if (err) {
              resolve(null);
          }
          else {
              resolve(addresses);
          }
      });
  }).then(listOfMX =&gt; { // here i'm looking for value with lowest priority
      return arr = listOfMX.reduce((previous, current) =&gt; {
          if (previous.priority &lt; current.priority) {
              return previous
          }
          return current;
      })
  }).then(response =&gt; {
      console.log(response[0]);
      return response.exchange; // i get {exchange:&quot;smtp.aspko.com&quot;, priority: 5}, and from this i return only the exchange
  }).catch(err =&gt; {
      console.log(err);
  });
  };
  async function f() { // async function to solve the Promise &lt;pending&gt;
     const response = await getMX();
     console.log(response)
  };
  
  f(); // here i call the main function
  </code></pre>
  <p>Anyway i still see or Promise  or undefined and i can't just add a return in async function f(), which will solve my problem (when i will call f() it should return me the one value, but instead i see undefined)</p>