I'm trying to retrieve the customer's IP address during Iron Router's routing process. I have a server-side function for this (getIP), however the "waitOn" function inside the route won't wait for the server function to return:
waitOn: function () {
Meteor.call('getIP', function(error, clientIp){...}}
Can I force it to wait, or can I get the IP in any other way?
According to the documentation, the waitOn hook must return a Handler, a function or an array. the reason why it's not working for you, is that Meteor.call on the client is always async, and you have to define a callback function, which is called when the method responds. Given that nature, you could only use the Meteor method, if the waitOn code supported a Promise, that could be resolved on the method callback.
The only way I see this is the following:
I hope this helps and that it works for you.