title: NodeJS MVC asynchronous request
body: <p>I'm getting undefined data from controller to model request in NodeJS.</p>
  
  <p>My Model:</p>
  
  <pre><code>const db = require('../util/database');
  
  module.exports = class Property {
      constructor(pID) {
  
      }
  
      getPropertyByID(pID) {
          let property = {};
          db.execute('SELECT * From Properties Where PropertyID = ' + pID)
              .then(res =&gt; {
                  const data = res[0][0];
                  if(data){
                      //console.log(data); This shows DATA if I remove the comment
                      property = data;
                  }
                  return property;
              })
              .catch(err =&gt; {
                  console.log(err);
              });
      }
  }
  </code></pre>
  
  <p>Then, in my controller I tried to use the Model method.</p>
  
  <pre><code>exports.sendDataID = (req, res, next) =&gt; {
     const propID = req.params.propID;
     if(propID) {
        const property = new Property();
        const data = property.getPropertyByID(propID);
        console.log(data);
     }
  };
  </code></pre>
  
  <p>The console.log(data) is returning undefined. Why is it happening?</p>
  
  <p>Thanks</p>