所以在我的/xyz.component.ts 中,我从/user.ts 调用resetPassword 方法。在 LoopBack 文档中它说:
调用 User.resetPassword 最终会发出一个 resetPasswordRequest 事件并创建一个临时访问令牌。
但是我如何捕捉事件?如果我尝试应用 .on('resetPasswordRequest', ()=>{....}) 它告诉我 UserApi 没有“on”。
/xyz.component.ts
private resetPassword(){
this.userApi.resetPassword({email: this.userName}).subscribe((data : any)=>{
console.log(data);
},(error : any) => {
this.error = error;
}
);
console.log("error: " , this.error);
}
/user.ts
public resetPassword(options: any, customHeaders?: Function): Observable<any> {
let _method: string = "POST";
let _url: string = LoopBackConfig.getPath() + "/" + LoopBackConfig.getApiVersion() +
"/Users/reset";
let _routeParams: any = {};
let _postBody: any = {
options: options
};
let _urlParams: any = {};
let result = this.request(_method, _url, _routeParams, _urlParams, _postBody, null, customHeaders);
return result;
}