【发布时间】:2022-01-23 05:48:24
【问题描述】:
我在测试时不断收到此错误:未捕获错误:未捕获(承诺中):TypeError:this._productService.getProducts(...).toPromise is not a function。
我知道 toPromise 在 rxjs 版本 7 中已被弃用,但我正在运行版本 6。有没有办法解决这个问题或以其他方式在不使用 toPromise 的情况下编写我的代码?
我根据之前点击定义的三个输入来获取我的产品。
谢谢。
async ngOnInit(): Promise<void> {
this.product = await this._productService
.getProducts({
InputOne: this.inputOne,
InputTwo: this.inputTwo,
InputThree: this.inputThree
})
.toPromise();
}
【问题讨论】:
标签: angular unit-testing service promise rxjs