无法调用Meteor Call功能

时间:2015-05-25 05:43:58

标签: meteor

SERVER

if (Meteor.isServer) {
          Meteor.startup(function () {
            // code to run on server at startup


          }

    Meteor.methods({
        getApiResult: function() {
            try {
                var pipeline = [{$match: {"ACTIVE": 1}}, {"$group": {"_id": "$VARIENTS.NAME"}}, {
                    "$project": {
                        "_id": 0,
                        "TEMPLATE_NAME": "$_id"
                    }
                }];

                console.log("display pipeline");
                console.log(pipeline);
                var result = nodeDB.aggregate(pipeline);

                console.log("display result", result);

                for (i = 0; i < result.length; i++) {
                    var Temp_Name = result[i];
                    console.log("temp name is ", Temp_Name);
                    //productDB.insert({ Temp_Name: $(". Temp_Name").val()});
                    return result;

                }
            }catch (_error) {
                return false;
            }

        });

    }
    }

客户端

if (Meteor.isClient) {
  //error here   **Meteor.call**('getApiResult', function(err, result) {
          if (result) {
              console.log("reached meteor call")
              console.log(result);
          }
      });
};

错误:  标记为

的行的意外标识符

2 个答案:

答案 0 :(得分:1)

if (Meteor.isClient) {
  //error here   **Meteor.call**('getApiResult', function(err, result) {
      if (result) {
          console.log("reached meteor call")
          console.log(result);
      }
  // }); // remove line Meteor.call end 
};

删除Meteor.call结束});

答案 1 :(得分:1)

你有很多关于sintaxis的问题!

服务器

1.11:52:52.6477489 

客户端

CREATE TABLE [schema].[sampletable](
    [RecordNo] [int] NOT NULL,
    [ID_NO] [nvarchar](50) NOT NULL,
    [NAME] [nvarchar](200) NULL,
    [Status] [varchar](20) NULL
)