Header in http.get() in ionic 3

i want to put header in get request in http
how i can do this in ionic 3

By reading the Angular documentation over here:


quick excerpt:

import { Headers, RequestOptions } from '@angular/http';

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

    return this.http.post(this.heroesUrl, { name }, options)

thanks you
{ name }
stand for what

It’s a post, so name is the payload. But if you wouldn’t be that lazy and opened up the docs, you would have probably seen that :wink: If you do a get request, a payload isn’t necessary. Just pass in the options.

1 Like