How to set this.http.get Header

I’ve searched and tested a lot of code but still not able to set header for http get request.
Here is my sample code:

  1. import
    import { Http, Headers } from '@angular/http';
  2. inside constructor
  constructor(public navCtrl: NavController, public http: Http, public headers: Headers) {
       this.headers.append('Content-Type': 'application/json' );
       this.headers.append('more_header_option', 'value');

       this.http.get('http://some_url.com/api/get_json_feed', {headers: this.headers})
                  .subscribe((res) => { this.data = res.json(); }); 

 }

I’m gettting below error in the console

error TS2304: Cannot find name 'RequestOptions'.

Any help, highly appreciated …thank you

You shouldn’t inject Headers into your constructor, and you need to pass RequestOptions to http.get. Example straight from the HTTP Client docs:

  addHero (name: string): Observable<Hero> {
    let body = JSON.stringify({ name });
    let headers = new Headers({ 'Content-Type': 'application/json' });
    let options = new RequestOptions({ headers: headers });

    return this.http.post(this.heroesUrl, body, options)
                    .map(this.extractData)
                    .catch(this.handleError);
  }

Thanks for the help …I think I’m almost there, but still getting some errors

Return type of public method from exported class has or is using name 'Observable' from external module "C:/ionic2/technotip/node_modules/rxjs/Observable" but cannot be named.

a request returns an observable. if you are using additional operators oder observable functions like .map you need to import them.

import 'rxjs/add/operator/map'

I’ve added / imported it, still I’m getting the same error.

See if this helps: [Solved] Ionic RC0: error TS4053: Return type of public method from exported class has or is using name 'Entry' from external module

Followed it and now getting ‘No provider for Headers!’ error message :frowning:

hi@technotip
Did you found the solution.New to ionic :neutral_face:
Thanks,