I am creating method which saves customer in database and return response in json format back to calling method. Here is my Code:
Meteor.methods({
'Registration': function() {
name = "Hardik";
contact = "";
email = "admin@gmail.com";
password = "123";
Meteor.setTimeout(function() {liveDb.db.query('Insert Into Customer (Customer_Name, Customer_Contact, Customer_Password, Customer_Email) values ("'+name+'","'+contact+'","'+password+'","'+email+'")',
function(error, result){
if(result!='undefined' && result.affectedRows>0)
{
var r = {message : "Customer Added Successfully.", statuscode: "200", customerid : result.insertId};
return r;
}
else
{
var r = {message : "Something Went Wrong", statuscode: "400", error : error};
return r;
}
});},1000);
}
});
But when I try to fetch returned value in client I am getting nothing Client Side Code:
Meteor.call('Registration', function (error, result) {
console.log(result);
});