Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7932125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:55:21+00:00 2026-06-03T20:55:21+00:00

I am having trouble getting a server Meteor.method to return a successful response when

  • 0

I am having trouble getting a server Meteor.method to return a successful response when I wrap the return in a callback.

It works fine when not wrapped in a call back.

It can throw new Meteor.errors both when wrapped in a call back and when not wrapped in a call back.

Wrapping the Meteor.call on the client side in this exact same fashion works fine.

But, for some reason doing this on the server does not return a response value when return is called.

Here is an example. This is not my exact code but very close. It is very close though.

Meteor.methods({
  insertData: insertData
});

function insertData(params){
 validateParams(params, function(bool, msg){
  if(bool){
    //do stuff, like insert records
    result = 'thanks a million gagillions';
    console.log(result);
    return result;
  } else {
    throw new Meteor.Error(513, msg);
  }
 });
}

validateParams(params, callback){
  for (var key in params) {
    value = params[key];
    if(_.isEmpty(value) || _.isUndefined(value) || _.isNull(value)) {
      callback(false, 'Please enter your "'+ key + '".'); 
      return;
    }
  }
  callback(true);
}

How do I get this to work so that the result is returned?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:55:23+00:00Added an answer on June 3, 2026 at 8:55 pm

    You don’t need callbacks here. You might find the straight-line code more readable.

    Meteor.methods({
      insertData: insertData
    });
    
    function insertData(params){
      // run validator, allow exception to propagate
      validateParams(params);
    
      //do stuff, like insert records
      result = 'thanks a million gagillions';
      console.log(result);
      return result;
    }
    
    function validateParams(params){
      for (var key in params) {
        value = params[key];
        if(_.isEmpty(value) || _.isUndefined(value) || _.isNull(value))
          throw new Meteor.Error('Please enter your "'+ key + '".');
      }
      // not strictly necessary, just don't throw exception.
      return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is anyone else having trouble getting with their mysql server not starting with lion.
I'm having trouble getting the following to work in SQL Server 2k, but it
I am writing a Resteasy server application and am having trouble getting my superclasses
I'm having trouble getting a client/server implementation of Quartz.NET working. I have a SQL
I'm working on a client/server and I'm having trouble getting them to communicate over
Does ADO.NET Entity Framework 4 work with SQL Server 2005? I'm having trouble getting
I'm having trouble getting this script to work. <asp:DropDownList CssClass=workUnit Width=80 ID=dropdownWorkUnit runat=server Visible=false
I'm having trouble getting my ASPX-App to work on the productive server. As my
I just got a Windows Server 2008 VPS and I'm having trouble getting IIS7
I'm having trouble getting Code Analysis to run on the build server. My goal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.