I tried calling Router.go('confirmation') to take the user to confirmation page once the information has been inserted into the database.
Meteor.methods({
'createNewItinerary': function(itinerary){
var userId = Meteor.userId();
ItineraryList.insert({
[....values.....]
},function(){
Router.go('confirmation');
});
}
In the server console, I get the response: has no method 'go'
The data is inserted successfully, so how do I get it to route to a confirmation page?
-- Edit --
Will this work? It seems to but don't know how to verify:
Meteor.call('createNewItinerary',itinerary, function(err, data){
if(err){
console.log(err);
}
else Router.go('confirmation');
});
Your suggestion is the good choice to make. You can't catch the Router in a Meteor method because it's server side. You have to do it in the callback function, exactly like you suggested :
Meteor.call('createNewItinerary',itinerary, function(err, data){
if(err){
console.log(err);
}
Router.go('confirmation');
});
To check that the work has correctly been done on the server, just throw errors, for example:
throw new Meteor.Error( 500, 'There was an error processing your request' );
Then if error is thrown, it will be logged in your client side.
Hope it helps you :)