Kaynağa Gözat

W3.5: store the result of a method call.

Frederic G. MARAND 9 yıl önce
ebeveyn
işleme
6ffdbc0ba5
1 değiştirilmiş dosya ile 8 ekleme ve 2 silme
  1. 8 2
      textcircle.js

+ 8 - 2
textcircle.js

@@ -61,7 +61,12 @@ if (Meteor.isClient) {
         alert("You need to login first.");
       }
       else {
-        Meteor.call("addDoc");
+        Meteor.call("addDoc", function (err, res) {
+          if (!err) {
+            console.log("addDoc res", res);
+            Session.set("docid", res);
+          }
+        });
       }
     }
   });
@@ -90,7 +95,8 @@ Meteor.methods({
         createdOn: new Date(),
         title: "my new doc"
       };
-      Documents.insert(doc);
+      const docid = Documents.insert(doc);
+      return docid;
     }
   },