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.
Here is my function :
//controller / form.js;
exports.createFormsElement = (req, res) => {
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 => {
return data;
});
}
}