title: How to pass one function result to another function in Node.js
body: <p>I have function to create inside of it; I am checking if it's created or not by calling another helper function, but I'm unable to return that helper function result; if I did I can get only as undefined. </p>
  
  <p>Here is my function :</p>
  
  <pre><code>//controller / form.js;
  exports.createFormsElement = (req, res) =&gt; {
    console.log("Post a Elements: " + JSON.stringify(req.body));
    formById = formsHelper.formById("1");
    console.log("formById" + formById);
    res.send({ result: formById ? formById : "empty" });
    return;
  };
  
  //helper/forms.js 
  module.exports = {
      formById: function(idForms) {
          Forms.findOne({
              where: {
                  idForms: idForms
              },
              attributes: ['idForms']
          }).then(data =&gt; {
              return data;
          });
      }
  }
  </code></pre>