I am trying to call a log function which is in the document using interceptor in LoopBack 4 as illustrated below;
@intercept(log) // `log` is an interceptor function
export class PingController {
}
log function in LoopBack 4 docs
const log: Interceptor = async (invocationCtx, next) => {
console.log('log: before-' + invocationCtx.methodName);
// Wait until the interceptor/method chain returns
const result = await next();
console.log('log: after-' + invocationCtx.methodName);
return result;
};
But I get an error;
cannot find name Interceptor
What am I doing wrong and how can I resolve it?
import { Interceptor } from '@loopback/context';
Able to get Interceptor Object from @loopback/context latest version