有时候会遇到这种情况,在a函数调用完之后再调用b函数接口,这时候就要用到angular http同步请求,下面是一种案例:
//getDetails public async getLocationDetails(): Promise<any>{ let customBody = { "appID" : APP_CONfig['appID'], "apiVersion" : 2, "eventID" : atob(sessionStorage.getItem('lyc_event_id')), } const locationDetailsRes=await this.httpService.callEMP(environment.API.getEventInfo,customBody).toPromise() if(locationDetailsRes["status"] == '0'){ /** * 0 is mean success. other status value is mean error **/ sessionStorage.setItem('currentLocationName',locationDetailsRes['event']['eventName']) }else{ this.snackBar.open(this.translateService.instant('General.Error.something_went_wrong_text'), '×', { panelClass: 'error', verticalPosition: 'top', duration: 5000 }); } }
public async onLoginFormSubmit() { await this.getLocationDetails(); }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。