Meteor JS - Exception from subdirectory (id, which is not)

I20150615-07: 11: 17.859 (9)? Exception from sub draftsList id Error GghnkQkdjNSTyHuQs: Match error: Expected object received by undefinedI20150615-07: 11: 17,859 (9)? on checkSubtree (packages / check / match.js: 275: 1) I20150615-07: 11: 17.859 (9)? in check (packages / check / match.js: 32: 1) I20150615-07: 11: 17.859 (9)? in [object Object] .Meteor.publish.Meteor.users.find.userId [as _handler] (app / server / publications.js: 44: 3) I20150615-07: 11: 17.859 (9)? c Maybe AuditArgumentChecks (packages / ddp / livedata_server.js: 1617: 1) I20150615-07: 11: 17,859 (9)? in [object Object] ._. extend._runHandler (packages / ddp / livedata_server.js: 950: 1) I20150615-07: 11: 17.859 (9)?
in [object Object] ._. extend._startSubscription (packages / ddp / livedata_server.js: 769: 1) I20150615-07: 11: 17.859 (9)?
in [object Object] ._. extend.protocol_handlers.sub (packages / ddp / livedata_server.js: 582: 1) I20150615-07: 11: 17.859 (9)?
in packages / ddp / livedata _server.js: 546: 1 I20150615-07: 11: 17.860 (9)? Sanitized and reported to the client as: Failed to complete match [400]

I am working on a meteorite project and I am getting this strange error on my terminal.

The problem is when it says the Exception from sub draftsList id GghnkQkdjNSTyHuQs Error: Match error: Expected object, got undefined

id always changes on page refresh and is not in my database (not visible anywhere).

The point is that everything works.

Here is my publication-subscription

Publication

Meteor.publish('draftsList', function (options) {   
  check(this.userId, String);
  check(options, {
    limit: Number
  });

  var drafts = Drafts.find({'user._id': this.userId}, options);

  return drafts;
});

      

Subscription

Router.route('/posts/:_id', {
  name: 'postPage',
  // limit: function () {
  //   return
  // }
  subscriptions: function () {
    return [
      Meteor.subscribe('singlePost', this.params._id),
      Meteor.subscribe('userStatus'),
      Meteor.subscribe('draftsList'),
      Meteor.subscribe('draftsList', {
        limit: Number(Session.get('draftsLimit'))
      }),
      Meteor.subscribe('comments', {
          postId: this.params._id
        }, {
          limit: Number(Session.get('commentLimit'))
      }),
      Meteor.subscribe('answers', {
          postId: this.params._id
        }, {
          limit: Number(Session.get('answerLimit'))
      })
    ];
  },
  data: function() {
    return Posts.findOne({_id:this.params._id});
   },
});

      

+3


source to share


2 answers


You subscribe draftsList

twice on your itinerary. The first subscription without any parameters, which will make options

be undefined

instead of an object. Just remove the first subscription and the problem should go away.



Also note that using check

for this.userId

might work in this case, but might cause problems if you used waitOn

in your route. A common pattern is to return []

or this.ready()

when this.userId

present undefined

at a publisher that requires an authenticated client.

+1


source


Try to remove your check

cons this.userId

in your post, you don't need to check its validity, as Meteor already does it for you.



Meteor.publish('draftsList', function (options) {   
  check(options, {
    limit: Number
  });
  var drafts = Drafts.find(this.userId, options);
  return drafts;
});

      

0


source







All Articles