I am trying to load data from a rest endpoint using the HttpClient provided by Angular. The endpoint in question uses a token to authorize the user. 

```
    getData() {
     if (this.token) {
        const httpOptions = {
        headers: new HttpHeaders({
          'Content-Type':  'application/json',
          'Authorization': 'Bearer' + ' ' + this.token
       })
     };
     this.http.get('https://some url', httpOptions).subscribe((res) => {
       console.log(res);
     }, (error) => {
       console.log(error);
     });
     } else {
       this.empty_token = true;
     }
   }

```

I get the following error while trying to do that: 
**Response for preflight has invalid HTTP status code 401.**

However, the same code works for a some demo url that works on **"http"** and not for **"https"**.

I tried using the same by making a request using Postman or any other RestClient for that matter and it works fine.