1

Am new to loopback, am trying to console request.body in loopback 4 to view the incoming data, but if i print it it prints as undefined, i know i need to use body parser package here, but i can't able to figure it how to use it with LB4? Any help will be appreciated

export class MySequence extends MiddlewareSequence {
  async handle(context: RequestContext): Promise<void> {
    const {request} = context;

    console.log({body: request.body});

    await super.handle(context);
  }
}
Kannan T
  • 1,639
  • 5
  • 18
  • 29

1 Answers1

0
return async function tracker(req, res, next) {
    req.on('data', function (chunk) {
      console.log("chunk", JSON.parse(chunk))
    });
}

You can use this in the middleware function to log request body

Mubas Akz
  • 26
  • 4