How to make a synchronous call in angular 5?

后端 未结 5 1231
我寻月下人不归
我寻月下人不归 2021-01-11 11:33

So, I was trying to get the solution of this problem. But, somehow I am unable to do so, May be because of the lack of knowledge in angular 5. This is my service:

         


        
5条回答
  •  甜味超标
    2021-01-11 12:13

    Subscribe to GetCurrentUserData() the http call is async (every browser api call is async, because the javascript engine runs in a single thread (google for browser event loop for more, this is not an angular issue))

    this.GetCurrentUserInformation().subscribe((data: ResponseData) => {
            if (this.responseData.code != responseCodes.success) {
                this.googleInit();
            }
    });
    

提交回复
热议问题