title: angular2 download file with post request
body: <p>I have a button defined as:</p>
  
  <pre><code>&lt;button pButton type="button" label="Download" data-icon="fa-cloud-download" (click)="download()"&gt;&lt;/button&gt;
  </code></pre>
  
  <p>where the <code>download</code> method delegates to a service, and the service call the api with a post method:</p>
  
  <pre><code>download(model:GlobalModel) {
          let downloadURL = base + "rest/process/download";
          let body = JSON.stringify(model);
          let headers = new Headers({'Content-Type': 'application/json'});
          let options = new RequestOptions({headers: headers});   
  
          this.http.post('http://localhost:48080/rest/process/download', body, options)
              .toPromise()
              .then(
                  response =&gt; {
                      console.log(response);       
                      var mediaType = 'application/zip';
                      var blob = new Blob([response.blob()], {type: mediaType});
                      var filename = 'project.zip';
                      saveAs(blob, filename);//FileSaver.js libray
                  });
  
      }
  </code></pre>
  
  <p>But by now the <code>blob()</code> method has not been implemented and there are other answers using <code>_body</code> but there is an typescript error like "_body is private".</p>
  
  <p>The browser displays the download window, but when I download the file is corrupted and cannot open it (I check with <code>postman</code> and the file is generated OK from the server).</p>
  
  <p>How could I download a file properly?... if not possible, There is available a workaround?</p>