title: How to convert an http.get.("URL").subscribe to a promise so that I can await it?
body: <p>How can I convert the http.get.subscribe to await so that I can wait for it before going on to the next code?
  The problematic function is this:</p>
  
  <pre><code>async ngOnInit() {
      await this.setupIngredients();
  
      console.log("this text should be displayed after FINISHED");
      otherCode();
      //....other code
  }
  </code></pre>
  
  <p>I want the <code>otherCode()</code> and the <code>console.log("this text should be displayed after FINISHED");</code> to execute after the <code>setupIngredients()</code> has finished.</p>
  
  <p>My setupIngredients function is this:</p>
  
  <pre><code>setupIngredients() {
      this.indicatorDataService.http.get(this.baseGetUrl + "entity=ingredients&amp;indicator=all").subscribe(res =&gt; {
          // do something with res
  
  
      });
  }
  </code></pre>
  
  <p>I still don't know why it won't convert to a correct Promise. I tried replacing the subscribe with toPromise, but still it doesn't work.</p>