title: Promise in Angular 9
body: <p>I'm trying to write a synchronous function call in Angular using a Promise, but it still gets a different result than expected.
  I have 2 functions that use the service that download data from the API:</p>
  
  <pre><code>getData1(shortcut: string): void {
    this.apiServ.getPrice(shortcut).subscribe(
      (price: CurrentPrice) =&gt; {
        this.price = price;
        console.log(1);
      },
      error =&gt; this.error = error
    );
  }
  
  getData2(shortcut: string): void {
    this.apiServ.getPrice(shortcut).subscribe(
      (price: CurrentPrice) =&gt; {
        this.price = price;
        console.log(2);
      },
      error =&gt; this.error = error
    );
  }
  </code></pre>
  
  <p>I'm trying to make the next function call after the response is completed. So:</p>
  
  <pre><code>data(shortcuts) {
    this.getData1(shortcuts[0]);
    this.getData2(shortcuts[1]);
  }
  
  ngOnInit() {
    const myPromise = new Promise((resolve) =&gt; {
      this.data(this.shortcuts);
      resolve(3)
    });
    myPromise.then((value) =&gt; {console.log(value)});
  }
  
  </code></pre>
  
  <p>But my browser prints this call order:</p>
  
  <pre><code>3 
  1 
  2
  </code></pre>
  
  <p>What am I doing wrong? <br>
  I also tried to use callbacks but the effect is always the same.</p>