Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override GET or any default method on strongloop

I need to override the GET on strongloop. So when I GET foo/ it returns something different as the default one.

I tried using remoteMethod with http: {path: '/', verb: 'get'} without success.

How can I override any default method on strongloop?

like image 232
perseus Avatar asked Feb 10 '16 22:02

perseus


1 Answers

Finally I found it. So get corresponds to find without any filter.

So the code is:

Foo.on('attached', function() {
  Foo.find = function(filter, callback) {
    //Whatever you need to do here...
    callback(null, {hello: 'hello'});
  }
});

Here there is a link for all the PersistedModel methods

I just put 'attached' without exactly knowing why so if someone can comment the reason it would be great.

like image 183
perseus Avatar answered Oct 19 '22 20:10

perseus