Remove or redefine defined meteor methods?

Hi, sorry if this is a stupid noob question, but I’m wondering if it’s possible to remove or redefine an already defined meteor method? Something like the following:

Meteor.methods({
    "doFoo": function() {
        // do something here
    }
});

// somewhere else in code, something like: 
Meteor.removeMethod('doFoo');

Necromancing your question :slight_smile: I needed to do this for a password rotation scheme.

Here’s what I came up with:

// First, we delete the existing handler
delete Meteor.server.method_handlers.changePassword;
delete Meteor.default_server.method_handlers.changePassword;

// Next we redefine the method.
Meteor.methods({changePassword: function (oldPassword, newPassword) {
    ...
  }
});

Ugly, but seems to work.

This is what I used in Reval https://github.com/qualialabs/reval/blob/master/packages/qualia_reval/server/plugins/methods.js#L15

1 Like

Hey @veered, interesting!

Did you need to modify the client to work with the new version of the method?

Our intent is to replace the method server side with the same parameters…

Only if the meteor method is also defined on the client; this is usually not the case

1 Like