I implemented a very simple Meteor method which is defined on server side only and is called by the client. From time to time the method is not called on the server but the client performs a simulation (and does not even run through the server method) which returns an undefined result but no error and therefore the client code fails. As the server side method is defined in a file that is available on the server only I expect the client not to run a simulation as described here.
For the following small example I would simply like to define that no simulation is performed at all but the calling client code fails, when the server is unavailable. Can someone give me a hint about what I am doing wrong or what I am missing to get this simple example working as expected?
Thank you very much…
// Server code (defined in /imports/api/.../server/server-method.js)
// I also tried /server/server-method.js with the same result
Meteor.methods({
getSecureString: function() {
if (this.userId == null) {
throw new Meteor.Error(
'No user logged in. Please login in user and try again.'
);
}
return {
stringValue: 'This is a test...',
};
},
});
// Client code
Meteor.call('getSecureString', function(error, result) {
if (error) {
console.error(error.message);
// alert(error);
} else {
console.log('Secure-String: ' + result.stringValue);
}
});