Typescript 环回-失败,状态代码为500。TypeError:this.workflowService.createNotification不是函数
我正在使用loopback4开发一个微服务。我试图点击第三方RESTAPI,并严格遵循loopback4文档。 当我点击controller/upload/workspace时,我得到的错误是 this.workflowService.createNotification不是函数 我的依赖项:Typescript 环回-失败,状态代码为500。TypeError:this.workflowService.createNotification不是函数,typescript,loopback4,Typescript,Loopback4,我正在使用loopback4开发一个微服务。我试图点击第三方RESTAPI,并严格遵循loopback4文档。 当我点击controller/upload/workspace时,我得到的错误是 this.workflowService.createNotification不是函数 我的依赖项: "@loopback/boot": "^3.3.1", "@loopback/core": "^2.15.1", "
"@loopback/boot": "^3.3.1",
"@loopback/core": "^2.15.1",
"@loopback/repository": "^3.5.1",
"@loopback/rest": "^9.2.1",
"@loopback/rest-explorer": "^3.2.1",
"@loopback/service-proxy": "^3.1.1",
控制器:
export class WorkflowController {
constructor(
@inject('services.workflow')
protected workflowService: Workflow
) {}
@post('/upload/workflow')
@response(200, {
description: 'Action model instance'enter code here
})
async create() {
console.log(this.workflowService)
return this.workflowService.createNotification();
}
}
服务:
export interface Workflow {
// this is where you define the Node.js methods that will be
// mapped to REST/SOAP/gRPC operations as stated in the datasource
// json file.
createNotification(): any;
}
export class WorkflowProvider implements Provider<Workflow>{
constructor(
@inject('datasources.notification')
protected dataSource: NotificationDataSource = new NotificationDataSource(),
) {}
value(): Promise<Workflow> {
return getService(this.dataSource);
}
}
const config = {
"name": "notification",
"connector": "rest",
"baseURL": "http://localhost:5001",
"crud": true,
"options": {
"baseUrl": "",
"headers": {
"accept": "application/json",
"content-type": "application/json"
}
},
"operations": [
{
"template": {
"method": "POST",
"url": "/notifications",
"headers": {
"content-type": "application/json"
}
},
"functions": {
"createNotification": []
}
}
]
};
@lifeCycleObserver('datasource')
export class NotificationDataSource extends juggler.DataSource
implements LifeCycleObserver {
static dataSourceName = 'notification';
static readonly defaultConfig = config;
createDeployment: any;
constructor(
@inject('datasources.config.notification', {optional: true})
dsConfig: object = config,
) {
super(dsConfig);
}
}