I'm a student and just started to learn Angular 7 and .Net Core 2.0
I have created some sessions in my controllers in .Net Core API and need to call them to implement some route protection in angular and so I have made this function in the below image which call the session from API to check whether to allow the route or not in Angular.
This is what my controller looks like
now what happening is when i make a call it hits the controller but because it is asynchronous the execution of angular keeps continuing rather than first waiting for the data to come from API because based on that data my canActivate()
function in Angular is going to return true or false,
by the time data is fetched and stored in variable my line no. 38 in the image had already been executed and I have set it to be false by default.
please help how to call the data synchronously so that the data is first fetched from the API and then it hits the last line after in Angular.