title: Angular Spring Download JSON File
body: <p>Can I use this method on different ports? Its working on port :8080 and i can download file but on :4200 i see only logs and nothing more.</p>
  <p>Method:</p>
  <pre><code>@GetMapping(&quot;/downloadJson&quot;)
      public ResponseEntity&lt;byte[]&gt; downloadJsonFile() {
          List&lt;Wine&gt; wines = wineService.findAllWines();
  
          String wineJsonString = jsonExporter.export(wines);
  
          byte[] wineJsonBytes = wineJsonString.getBytes();
  
          return ResponseEntity
                  .ok()
                  .header(HttpHeaders.CONTENT_DISPOSITION, &quot;attachment; filename=wines.json&quot;)
                  .contentType(MediaType.APPLICATION_JSON)
                  .body(wineJsonBytes);
      }
  </code></pre>
  <p>HTML:</p>
  <pre><code> &lt;a class=&quot;nav-link&quot; (click)=&quot;downloadFile()&quot;&gt;Download&lt;span class=&quot;sr-only&quot;&gt;(current)&lt;/span&gt;&lt;/a&gt;
  </code></pre>
  <p>Service:</p>
  <pre><code>public downloadJsonFile(): Observable&lt;any&gt; {
  return this.http.get&lt;any&gt;(`${this.apiServerUrl}/wine/downloadJson`)
  </code></pre>
  <p>}</p>
  <p>Component:</p>
  <pre><code>public downloadFile() {
      this.wineService.downloadJsonFile().subscribe();
    }
  </code></pre>