1

I need to log the request Parameters that comes to LoopBack Server and Log Response Parameters that goes out of LoopBack Server.

Currently , I am able to log and get request information for remote hooks but unable to fetch response information, does any one have idea regarding this.

For Example

Claim.afterRemote('updateByClaimNumber', function (ctx, claim, next) {
    var util = Claim.app.models.ModelsUtil;
    util.createInvocationLogs(ctx);
    next();
  });

Here ctx, has the request and response but not fetching response infor like response headers, body and statuscode.

Is there any other way of getting this information, I tried creating a middle ware to get request and response but cannot get it working.

Varun Jaiswal
  • 57
  • 3
  • 5

1 Answers1

0

At afterRemote hook you can only get response body as claim func argument, while response status and headers and not yet set.

You should listen for res.on('finish') event to get all response data.

IvanZh
  • 2,265
  • 1
  • 18
  • 26