javascript - Exception in async function: Only on server, not on localhost -
i trying route working function "thank you" page people buy our products on external store. on localhost works fine on our staging server following exception:
exception in callback of async function: action@http://taskwunderstaging-45398.onmodulus.net/12289f8cf999b67e6c6c6dcad1a5a5eded53f4e2.js:517:468
does have idea might causing this?
the code in question follows: iron router endpoint
router.route('/signup-partner', { name: 'signuppartner', where: 'client', waiton: function(){ return meteor.subscribe("packages"); }, action: function() { meteor.logout(function() {}); var query = this.params.query; //@todo verify query sha key! var userinfo = { email:query.email, firstname:query.firstname, lastname:query.lastname, }; var companyinfo = { companyname:query.company, street:query.street, city:query.city, zipcode:query.zipcode, country:query.country, taxid:query.taxid }; var orderinfo = { product:query.product, order:query.order, }; // package database orderinfo.package = packages.findone({digistoreid:orderinfo.product}).name; orderinfo.tw_id = packages.findone({digistoreid:orderinfo.product})._id; var data = { userinfo:userinfo, companyinfo:companyinfo, orderinfo:orderinfo, }; var = this; // check if user account exists , if add package , login user meteor.call("partneruserexists", data.userinfo.email,{orderid:data.orderinfo.order,tw_id:data.orderinfo.tw_id}, function(error, result){ if(result === "not-found"){ that.render('signup_partner',{ data: function(){ return data; } }); } else { session.set('boughtpackage',result); that.redirect('login'); } }); } });
the method route calls follows:
partneruserexists: function(email,orderids){ var user = meteor.users.findone({"emails.address":email}) || false; console.log(user); if(!user){ return "not-found"; } if(_.indexof(user.data.digistoreorders,orderids.orderid) > -1){ return orderids.tw_id; } (function(callback){ // add paidtask array if doesnt exist if (!user.data.paidtasks){ meteor.users.update({_id:user._id},{$set:{"data.paidtasks":[]}}); } // add digistore array if doesnt exist if (!user.data.digistoreorders){ meteor.users.update({_id:user._id},{$set:{"data.digistoreorders":[]}}); } callback(); })(function(){ meteor.users.update({_id:user._id},{$push:{"data.digistoreorders":orderids.orderid}}); meteor.users.update({_id:user._id},{$push:{"data.paidtasks":orderids.tw_id}}); return orderids.tw_id; }); }
check error in meteor.call. should tell if there error , why. if not, try putting console.log before each return. overall, see lot of user.xx fields being accessed without checking whether field set. 1 of those.
Comments
Post a Comment