title: Mongoose .findOne not working as an internal function call
body: <p>With this as a URL: </p>
  
  <blockquote>
    <p><strong>'api/support-tag/name/myTagName'</strong></p>
  </blockquote>
  
  <p>This function works properly:</p>
  
  <pre><code>    getByName: function (req, res) {
      model.Shared_SupportTag.findOne({name: req.params.name}).exec(function (err, results) {
          if (err) {
              return res.status(400).send({
                  message: errMsg.Util_ErrorMsg.getErrorMessage(err)
              });
          }
          res.send(results);
      })
  }
  </code></pre>
  
  <p>But when I try to call a similar function from within the node server:</p>
  
  <pre><code>supportDoc.category = GetById(item.category);
  
  function GetById(name){
      model.Shared_SupportTag.findOne({name: name}).exec(function(err, result){
          if(err){
              console.log(err)
          }else{
              console.log(result);
          }
      })
  }
  </code></pre>
  
  <p>The function does not execute, nor does the error catch, intellisense shows:</p>
  
  <pre><code> err= Reference error; err is not defined
  
   result = Reference error; result is not defined
  </code></pre>
  
  <p>All I am trying to accomplish is a function call from within the server and not via a URL.</p>
  
  <p>Any solution here? Thanks in advance</p>