1

When I Try to get REST API Call thow client side (Angular) but when i subscribe this at that time function will runing not wait for response so please help for hold on function.

GetLookup(){
  let Country = this.countryService.GetAllCountry().toPromise();
}

OR

GetLookup(){
 this.countryService.GetAllCountry().subscribe((obj){
  let Country = obj;
})
}

1 Answer 1

1

You Can Use async-await concept.

    async GetLookup(){
  let Country = await this.countryService.GetAllCountry();
}
Sign up to request clarification or add additional context in comments.

1 Comment

Angular is full plenty of Observables. Has no sense pass to Promise and use async. It's a work-around unnecessary

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.