gund / ng-http-interceptor

Http Interceptor library for Angular
MIT License
104 stars 16 forks source link

Can not append new headers to the intercepted request #144

Closed gbluv closed 7 years ago

gbluv commented 7 years ago

Is there a way to append headers via intercepter?

Thanks.

gund commented 7 years ago

Please follow readme page, from there you can deduct:

httpInterceptor.request().addInterceptor((data, method) => {
  const headers = getHttpHeadersOrInit(data, method);
  headers.set('X-Custom-Header', 'value');
  return data;
});
gbluv commented 7 years ago

Thanks, actually it was not very intuitive, you do mention that there is a getHttpHeadersOrInit but its hard to figure out where it should go. You might consider adding this specific example for better clarity.

Thanks again.

-Greg.

gund commented 7 years ago

Yeah maybe you are right, I just wanted not to bloat readme with extra examples to keep it as much clean as possible (since there are already a lot of code). Will this small example just to show how to use helper functions =) Thanks