title: How to make sync call in forEach loop Angular 6
body: <p>I am trying to check my all 4 images is uploaded to server without any error, then redirect to another page so i am trying to perform some sync checking in my code (I have total 4 images in my <strong>imgResultAfterCompress array</strong>). below is my code:</p>
  
  <pre><code>if(Boolean(this.updateImage(data.AddId))===true)
      {
       this.router.navigate(['/job-in-hotels-india-abroad']);
      }
  updateImage(AddId:number):Observable&lt;boolean&gt; 
  {
    this.cnt=0;
    this.uploadingMsg='Uploading Images...';
          this.imgResultAfterCompress.forEach( (value, key) =&gt; {
  
            if(value!=='')
            {
  
          this.itemService.updateImage(this.employer.ID,AddId,key,value).subscribe(data=&gt;{
            if(data &amp;&amp; data.status == 'success') {
              this.uploadingMsg=this.uploadingMsg+'&lt;br&gt;Image No - '+(key+1)+' Uploaded.';  
              this.cnt++;
              }
              else
                this.alertService.error(data.message);
  
            });
            }
            if(this.cnt==4)
            this.uploadingDone= true;
            else
            this.uploadingDone= false
          }); 
          return this.uploadingDone;
  }   
  </code></pre>
  
  <p>Every time i am getting <strong>cnt</strong> value is 0, i want its value = 4 (completely uploaded all images) then redirection will occurred.</p>