add header in angular

Solutions on MaxInterview for add header in angular by the best coders in the world

showing results for - "add header in angular"
Benjamín
02 Oct 2016
1import {Injectable} from '@angular/core';
2import {Http, Headers} from '@angular/http';
3
4@Injectable()
5export class HttpClient {
6
7  constructor(private http: Http) {}
8
9  createAuthorizationHeader(headers: Headers) {
10    headers.append('Authorization', 'Basic ' +
11      btoa('username:password')); 
12  }
13
14  get(url) {
15    let headers = new Headers();
16    this.createAuthorizationHeader(headers);
17    return this.http.get(url, {
18      headers: headers
19    });
20  }
21
22  post(url, data) {
23    let headers = new Headers();
24    this.createAuthorizationHeader(headers);
25    return this.http.post(url, data, {
26      headers: headers
27    });
28  }
29}
30
queries leading to this page
how to pass header in angularadd header angular http header in angularhow to set headers in angular 8angular new headersheaders 28 29 angularhtml header angularheaders angular 9angular get set headersangular 11 http add headeradd headers to get request angularadd headers to http request in angularadd header in get request angularaccess headers in angularangular http set headerset header angularset header in angular 4add header in angularadd headers to request angularangular setting http headersangular 10 add headers to http requestangular add headerangular html headeradd header in http request angularadd header to request angularadd header 22allow 22 in angular httpchanging header in angularangular 9 headersconstructing header in angularheaders angularinsert headers angularadd headers angularconstructing headers in angularhow to make header in angularangular http add custom headersset header in angularhow to add header in http request in angular 8how to create a header in angular header set in angularangular add header in requestheaders set angularupdate headers angularangular add custom headerhow to use headers in angularadd header in angular serviceset headers in angularhow to add header in angularsend headers in angular angular http put headersheader in angularangular add a new header to httpheaders 28 29add header angularcreeate header component angularhow to create header in angularangular http put with headersset headers tokne angularangular get with headersangular change headeradd header to post angularappend header in angular 8angular http add headersset header angular9header in angular 8make header in angular 8 angular set headersadd headers in http request angularhow to set header in angular 12angular add headers to http requesthow to set header in angularmanipulate header angular 9angular headersangular headerangular http set headersangular add custom header httpadd header in angular httpheaders in angularsend header angularadd header new angularhow to pass headers in angular 8add header server angularadd 7bheaders 3aheaders 7d in html angular 9custom headers http angularadd headers to angular requesthow to add custom header in http request in angularadd header to angular http requestadd header angfularadd header in angular