Sometimes gives json array empty or sometimes gives json array with values


const locat = new ReactiveVar(Tests.find().fetch());
export default locat;
console.log('on created ', this);
var findCollection = Tests.find().fetch();
this.locat = locat;


Probably because you’re not waiting for the subscription to be ready? So the server hasn’t sent you the data yet.


in what way i can do it ?


You can use the ready callback of the subscription:

If you subscribe via a Template, you can also use the subscriptionsReady helper: