title: How can we get HttpClient Status Code in Angular 4
body: <p>Hi new for Angular and i am facing problem for getting HTTP status code that is In HTTP Module I can easily get the response code using <strong>response.status</strong>, but when I used <code>HttpClient</code> Module I can not get the response.status, it shows can not find status.</p>
  
  <p>So, how can I get the response.status using <code>HttpClient</code> module in <code>Angular 4&amp;5</code>. Please help.</p>
  
  <h2>RestProvider:-</h2>
  
  <pre><code>@Injectable()
  export class RestProvider {
  
    private apiUrl = 'https://restcountries.eu/rest/v2/al';
  
    constructor(public http: HttpClient) {
      console.log('Hello RestProvider Provider');
    }
  
    getCountries(): Observable&lt;{}&gt; {
      return this.http.get(this.apiUrl).pipe(
        map(this.extractData),
        catchError(this.handleError)
      );
    }
  
    private extractData(res: Response) {
      let body = res;
      return body || { };
    }
  
    private handleError (error: Response | any) {
      let errMsg: string;
      if (error instanceof Response) {
        const err = error || '';
        errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
      } else {
        errMsg = error.message ? error.message : error.toString();
      }
      console.error(errMsg);
      return Observable.throw(errMsg);
    }
  
  }
  </code></pre>
  
  <h2>HomePage:</h2>
  
  <pre><code>export class HomePage {
  
    responseStatus: number;
  
    countries: any;
    errorMessage: string;
  
    constructor(public navCtrl: NavController, public navParams: NavParams, public rest: RestProvider) {
    }
  
    ionViewDidLoad() {
      this.getCountries();
    }
  
    getCountries() {
      this.rest.getCountries().subscribe(res =&gt;{
        this.countries=res;
        console("status code---&gt;"+res.status)
      },
      err=&gt;{
        console("status code---&gt;"+err.status)
      })
  
    }
  }
  </code></pre>