Passing arguments from one method to another?

I’m trying to pass an argument from one method to another method but I can’t seem to figure it out:

Meteor.methods({
    'method1'(connectedPostId) {
        return connectedPostId;  
    },
    'method2'() {
        collection.update({connectedPostId}, {
            #################
        });
    },

I know I cannot use session.set/get server side - but I really need to be able to send ‘connectedPostId’ from method 1 to 2 so I can dynamically choose which collection i’m updating

Thank you so much

You have to do the passing of the same arguments from the client instead

It might be worth noting that you can invoke methods from inside methods as well, so in method1 you could just fire a Meteor.call() for method2 and pass the relevant arguments like you would when invoking a method from somewhere else.

1 Like