Kegbreaker Kegbreaker - 4 months ago 22
Javascript Question

Meteor: Exception in delivering result of invoking method

Similar issues have been posted, but none quite match what I've run into. I'm doing a simple POST to an internal server to get back product data. The call is successful and I see the JSON data correctly logging to my terminal when I do a console.log on the server side. The issue arises on the client side, when in the callback, the result and error both are undefined.


ProductSearch: function(searchTerm) {
var method = 'POST';
var url = 'server';
var options = {
data: {
return, url, options, function (error, result) {
if (error) {
console.log("ERROR: ", result.statusCode, result.content);
} else {
var txt = JSON.parse(result.content);
console.log("SUCCESS: Found "+txt.totalResults+" products");

Client:'ProductSearch', searchTerm, function (error, result) {
if (error) {
console.log("error occured on receiving data on server. ", error );
} else {
var respJson = JSON.parse(result.content);
Session.set("productSearchResults", respJson);

When I log the values of error, and result on callback, they are both undefined, and I get the following error: Exception in delivering result of invoking 'ProductSearch': TypeError: Cannot read property 'content' of undefined


In your server-side method, you're not correctly returning the result of the, since you're using the asynchronous version, will return undefined and the result will only be accessible in the callback.

Use the synchronous version of instead and you'll be fine.

  var result =, url, options);
  return JSON.parse(result.content);

See the corresponding docs for for additional information.

asyncCallback Function

Optional callback. If passed, the method runs asynchronously, instead of synchronously, and calls asyncCallback. On the client, this callback is required.