title: Angular TypeError: Cannot read property 'length' of null in Promise subscribe()
body: <p>I am calling an API endpoint and receiving an error back but I can not view the error when using console.log because I get error below. Is there another way to get the error?</p>
  
  <p><strong>ERROR</strong></p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>TypeError: Cannot read property 'length' of null
      at http.js:109
      at Array.forEach (&lt;anonymous&gt;)
      at HttpHeaders.lazyInit (http.js:103)
      at HttpHeaders.init (http.js:251)
      at HttpHeaders.forEach (http.js:354)
      at Observable._subscribe (http.js:2153)
      at Observable._trySubscribe (Observable.js:172)
      at Observable.subscribe (Observable.js:160)
      at Object.subscribeToResult (subscribeToResult.js:23)
      at MergeMapSubscriber._innerSub (mergeMap.js:132)
  </code></pre>
  
  <p><strong>PROVIDER</strong></p>
  
  <pre class="lang-js prettyprint-override"><code>    import { HttpClient } from '@angular/common/http';
      import { Http, Headers , RequestOptions } from '@angular/http';
      import { Injectable } from '@angular/core';
  
      @Injectable()
      export class GamesProvider {
  
      // API url 
      apiUrl = 'http://xxxxx.com/api';
  
      headers : any;
      options: any;
  
      this.headers =  new Headers();
      this.headers.append('Accept', 'application/json');
      this.headers.append('Content-Type', 'application/json' );
  
      this.headers.append('Authorization', 'Bearer' + this.token);
  
      this.options = new RequestOptions({headers: this.headers});
  
      getUsers(ex) {
        return new Promise(resolve =&gt; {
         this.http.get(this.apiUrl+'/api/online/'+ex, {headers: this.options}).subscribe(data =&gt; {
          resolve(data);
         }, err =&gt; {
          console.log(err);
         }).catch((err) =&gt; {
  
                  // Do messaging and error handling here
  
                  return Observable.throw(err)
              });
       });
      }
  </code></pre>