我删除了一个类似于“公共异步ResponseHandler”的异步函数,但是抛出了错误Promise属性最终丢失了,不知道为什么只要将异步函数更改为常规函数就会发生这种情况?
handler.ts
export class AccountBalanceHandler {
public ResponseHandler(@Body()data: IAccountResponse ): Promise<any> {
return data;
}
}
main.ts
export class GetAccountBalanceController extends Controller {
private accountBalanceHandler: AccountBalanceHandler;
constructor() {
this.accountBalanceHandler = new AccountBalanceHandler();
}
private combineResults(data:any) : Promise<any> {
this.accountBalanceHandler.ResponseHandler(data.Details[1]);
}
}
AccountResponse.interface.ts
export interface IAccountResponse {
header: any;
details: IDetails;
}
export interface IDetails {
lineOfBusiness: string;
primary: IAccountBalanceDetails;
secondary: IAccountBalanceDetails;
}
export interface IAccountBalanceDetails {
balanceAccount: string;
beginningBalance: string;
endingBalance: string;
}
答案 0 :(得分:2)
听起来像您的true
方法上的类型错误。
尝试返回Promise或更改您的返回类型。例如
false
返回类型false
也被表示为一个承诺,但是您只是返回了combineResults
的输入。我不确定 private combineResults(data:any) : Promise<any> {
return this.accountBalanceHandler.ResponseHandler(data.Details[1]);
}
会做什么。