title: Using Angular Http.Get() synchronously
body: <p>I have a very simple requirement:</p>
  
  <p>I'm writing a authorization service for an Angular site (Angular 7 it makes a difference).
  The service needs a "hasPermission" function which takes a user and a resource name.  It makes an <code>Http.Get()</code> call to a backend to determine whether or not the user is authorized to access that resource.  When, and ONLY WHEN, the data comes back from the <code>Get()</code> call, it returns true or false.</p>
  
  <p>I have been searching the web for about a week trying to figure out how to do it.  My problem is that the <code>Http.Get()</code> returns an observable AND THEN CONTINUES.  Which means the function returns before it receives the data back on which to make a decision.  The same thing if I use the <code>Http.Get().toPromise()</code> - the function continues as soon as the promise is created.</p>
  
  <p>It seems like every "solution" I read is some variant of "return a promise" or "return an observable".  But then it's analagous to "It's turtles all the way down" -in this case, it's promises (or observables) all the way up.  At some point there needs to be a method that waits for and returns the data, not a promise of the data or an observable of the data.</p>
  
  <p>I need some way to add a "waitForDone" after creation of the observable or promise and before the function returns its value, but from everything I can find, you can't do that in JavaScript because it's single-threaded.
  Note, I can't, as some solutions have suggested, "Just put the code after the <code>http.get(...)</code> in a separate function and call it from success callback" because the code to be execute needs to return from this function.</p>
  
  <p>And async/await doesn't do it, because async turns the whole function into a promise, so, even though the await may wait for the <code>Get()</code> to return the data, the function will still have gone on and returned to the caller before it had the data it needed.</p>
  
  <p>It doesn't seem to me that this is an unusual requirement. While it's nice to be able to issue a request then go do something else while you wait for the data to come back, there have to  be times when you MUST HAVE the data before you can do anything else.</p>
  
  <p>Any help is appreciated.</p>