Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 环回-失败,状态代码为500。TypeError:this.workflowService.createNotification不是函数_Typescript_Loopback4 - Fatal编程技术网

Typescript 环回-失败,状态代码为500。TypeError: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", "

我正在使用loopback4开发一个微服务。我试图点击第三方RESTAPI,并严格遵循loopback4文档。 当我点击controller/upload/workspace时,我得到的错误是

this.workflowService.createNotification不是函数

我的依赖项:

"@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);
  }
}