title: How can i Make a fetch function to get json data from an api that requires authentication headers?
body: <p>I am using rapidapi to get some data from a football app but can understand why this throw this error.</p>
  
  <p>I have tried this code but it doesnt work, this shows this type of error</p>
  
  <pre><code>Response { type: "cors", url: "https://soccer-livescore.p.rapidapi.com/v1/global/getleague?league=Indo%20D3", redirected: false, status: 403, ok: false, statusText: "Forbidden", headers: Headers, body: ReadableStream, bodyUsed: false }
  </code></pre>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  import { HttpClient } from '@angular/common/http';
  
  @Component({
    selector: 'app-matches',
    templateUrl: './matches.page.html',
    styleUrls: ['./matches.page.scss'],
  })
  export class MatchesPage implements OnInit {
  
    constructor(public http: HttpClient){}
  
    ngOnInit() {
  
  
  fetch("https://soccer-livescore.p.rapidapi.com/v1/global/getleague?league=Indo%20D3", {
      "method": "GET",
      "headers": {
          "x-rapidapi-host": "soccer-livescore.p.rapidapi.com",
          "x-rapidapi-key": "not showing my rapid key"
      }
  })
  
  .then(response =&gt; {
      console.log(response);
  })
  .catch(err =&gt; {
      console.log(err);
  });
    }
  
  }
  </code></pre>