ray smith
ray smith

Reputation: 380

LoopbackJs hooks into relationship urls

If I have a url that's generated from a relationship /threads/{id}/messages how could I write a afterRemote hook that will execute after this query is finished?

Upvotes: 0

Views: 53

Answers (1)

xangy
xangy

Reputation: 1205

As per stated here by one of the maintainers of Loopback, you can use the followings to write remote hooks.

  • for POST /threads/{id}/messages

thread.beforeRemote('*.__create__messages__', function(ctx, inst, next) { ... });

  • for GET threads/{id}/messages

thread.beforeRemote('*.__get__messages__', function(ctx, inst, next) { ... });

  • for DELETE threads/{id}/messages

thread.beforeRemote('*.__delete__messages__', function(ctx, inst, next) { ... });

Upvotes: 1

Related Questions