Cant pass parameters through subscription

recently i have implemented a function for subscribe data with date parameters, the function working fine with chrome but not working in safari and firefox.

Weā€™ll need to see code to help. Both the server side publication handler and the client side code where you subscribe

server side publication method :-

Meteor.publish(ā€˜dataForReportā€™, function (fromDate,toDate) {

const user = Meteor.user();

if (!user) throw new Meteor.Error('not-authorized');

return Data.find(
  {
    clientId: user.profile.clientId,
    createdAt:{
      $lte:toDate,
      $gte:fromDate
    }
  }, 
  {
  fields: {
    deliveredByOwner: 0,
    clientId: 0,
  },
  sort: { createdAt: -1 }
});

});

client side subscribing function inside withtracker component:-

const data = Meteor.subscribe(ā€˜dataForReportā€™,fromDate.get(),toDate.get()).ready();

i am using reactiveVar for get dates

i have used moment package inside reactVar set function i just removed moment package function and use new Date function with date string then the issue fixed, do u have any idea about this.

The reason is that the MongoDB operators $lte and $gte can deal with the JS object Date out of the box. To make this work with momentjs you would have to invoke .toDate() on the momentjs objects.

E.g.
const data = Meteor.subscribe(ā€˜dataForReportā€™,fromDate.get().toDate(),toDate.get().toDate()).ready();

2 Likes

Thank you @peterfkruger issue fixed