LoopBack 版本 4 拦截器问题
LoopBack version 4 Interceptor issue
我正在尝试使用 LoopBack 4 中的拦截器调用文档中的日志函数,如下所示;
@intercept(log) // `log` is an interceptor function
export class PingController {
}
LoopBack 4 文档中的日志函数
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;
};
但是我得到一个错误;
cannot find name Interceptor
我做错了什么,我该如何解决?
import { Interceptor } from '@loopback/context';
能够从@loopback/context最新版本
获取拦截器对象
我正在尝试使用 LoopBack 4 中的拦截器调用文档中的日志函数,如下所示;
@intercept(log) // `log` is an interceptor function
export class PingController {
}
LoopBack 4 文档中的日志函数
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;
};
但是我得到一个错误;
cannot find name Interceptor
我做错了什么,我该如何解决?
import { Interceptor } from '@loopback/context';
能够从@loopback/context最新版本
获取拦截器对象