title: How to call a POST request in new tab in angular with authorization bearer token in header
body: <p>I am new angular. I am trying to call my rest service on a POST method, which will open a pdf document.</p>
  
  <p>I need to call the POST method in new tab, to get my pdf document from the service layer, with authorization bearer token added in header.</p>
  
  <p>Please suggest some angular way to achieve this.</p>
  
  <p>html</p>
  
  <pre><code>&lt;input type="button" value="Generate PDF" (click)="generatePDF();"&gt;
  </code></pre>
  
  <p>component.ts</p>
  
  <pre><code>generatePDF(){
  
  this.documentService.generatePDF();
  
  }
  </code></pre>
  
  <p>service.ts</p>
  
  <pre><code>httpOptions = {
     headers: new HttpHeaders(
     {
      'authorization': 'Bearer '+this.accessTolken
    })
  };
  
  generatePDF() {
  
  let payLoad = {
    'field1': 'field1',
    'field2': 'field2',
    'field3': 'field3',
    'field4': 'field4',
    'field5': 'field5'
  }
  
  const postUrl = `${this.serviceUrl}/pdfbypost`;
  this.http.post(postUrl , payLoad,this.httpOptions)
  .subscribe();                                           //Need something like this one
  
  window.open(postUrl , "_blank");                         // or this one
  
  
  }
  </code></pre>