How to append custom fields to HTTP Request header using Request class in Angular2? I found posts which solve similar problems, but they don't use Request class.
My code is the below.
let headers: Headers = new Headers();
headers.append('foo', 'bar');
let req: any = {
method : RequestMethod.Get,
url : '/test.json',
headers: headers,
};
// this.http is Http instance variable.
this.http.request(new Request(req)).map((res: any) => res.json());
This is very simple code. But when executing this, I couldn't find custom fields in HTTP request header using Developer Tools of Google Chrome.
Referenced: https://angular.io/docs/js/latest/api/http/index/Request-class.html
It's possible to reproduce this issue. The below code should get XHR 400 errors, but it's not problem. But note that the request header don't have custom fields.