I am new to Meteor, I am using MySQL database instead of MongoDB. I want to return mysql records from one of the Meteor Method at server and I am try to return same and at client side I want to print them into console. But it is printing as 'undefined'.
server.js
----------
import { Meteor } from 'meteor/meteor';
import mysql from 'mysql';
import { Mongo } from 'meteor/mongo';
Meteor.methods({
insertJobCurrent:function(EMPLID,callback) {
var pool = mysql.createConnection({
host: '127.0.0.1',
user: 'root',
password: 'abc1234',
database: 'dbEmployees'
//port: '31597'
});
var JobCurrent=[];
pool.query("SELECT A.EMPLID, B.NAME, A.JOBCODE, A.DEPTID, A.JOB_ENTRY_DT, A.SUPERVISOR_ID FROM Employee A JOIN names B ON A.EMPLID=B.EMPLID WHERE A.ACTIVE='Y' AND A.EMPL_RCD=0 AND A.EMPLID='"+EMPLID +"'", function (error, results, fields){
console.log(results); // Printing the results in Meteor console
return results;
});
//return jobCurrent.find().fetch();
}
});
client.js
--------
Meteor.call('insertJobCurrent',employeeID, function(err, response){
if (err) {
console.log("error: "+ err);
console.log(response);
} else{
console.log(response); // Printing undefined
console.log("success")
}
});
How can get the results at client side? Appreciate if anyone help me!
Copyright Notice:Content Author:「Sanjay」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/58197985/meteor-mysql-methods-are-not-returning-the-records