How to wait for a http request to finish in Angular?

前端 未结 3 969
野的像风
野的像风 2021-02-07 09:42

I\'ve been building a SPA with Angular 4 on the front end and ASP.NET Core 2 on the Backend. Basically, I\'m trying to automatically renew an user login, given a valid token. Wh

3条回答
  •  借酒劲吻你
    2021-02-07 10:21

    Use .toPromise on your observable followed by async/await.

    await this.net.get(`Authentication/GetUser`).toPromise();
    

提交回复
热议问题