I am toying around the some of the tutorials, the todo list is structured as follows: The server main.js imports a file, tasks.js, which describes some operations (some of which are in a "IsServer" statement") The client main.jsx imports App.jsx which imports the same tasks.js file
I wanted to add a call to an external service, so I've extended the server main.js (the one inside the /server folder) with a method like this:
Meteor.methods({
calloutMethod: function(id){
var apiUrl = 'http://someurl/'+id;
return HTTP.call(
"GET",
apiUrl
);
},...
now in the tasks.js, this file is somewhere inside the import folder and is imported also from the client, I've added:
Meteor.methods({
'tasks.insert'(id) {
...
Meteor.call('calloutMethod', id, function(error, result){
if(!error){
console.log(result);
}
});
I would like to call the method tasks.insert from the client, this method should call the calloutMethod hosted on the server.
When I put a console.log inside the server method I see the call happening and the result are displayed on the server console.. in the client console I immediately see "undefined" meaning that the callback function is immediately called:(
Is it because of this hybrid "import folder" making confusion? In my understanding of the documentation using Metor.call('name',params, function(err,res){... should make an asynchronous call to the server method, why is it not happening?