javascript - how to call a method async in meteor if having load of data while fetching server side -
hello have server side method calling method client side.the method works fine.but when return query result.then not show in client side. when return 'hello' shows in client side. issue query taking long time execute. if have idea response of query in client side code.below added code.
meteor.methods({ getresponsefromserver:function(latlong){ lng = parsefloat(latlong.lng); lat = parsefloat(latlong.lat); //return 'hello'; //this hello got in client side code. console.log(centers.find({ coordinates: { $near: { $geometry: { type: "point", coordinates: [lat,lng] }, $maxdistance: 10000 } } }).fetch()); //getting data server var getobject = centers.find({ coordinates: { $near: { $geometry: { type: "point", coordinates: [lat,lng] }, $maxdistance: 10000 } } }).fetch(); //getting data server , store in object , return return getobject; } }); and have client side code simple.
template.searchlist.onrendered(function(){ this.searchedstring = router.current().params.name; searchedparams = this.searchedstring; searchedparams = searchedparams.split('-'); var lat = searchedparams.pop(); var lng = searchedparams.pop(1); lng = number(lng).tofixed(6); console.log(lng); lat = number(lat).tofixed(6); var latlong = {'lat':lat,'lng':lng}; meteor.call("getresponsefromserver",latlong,function(error,success){ console.log(error+' see sucess here'); console.log(success+' see failure here'); }); }); please give me solution if have idea.
Comments
Post a Comment