Add a dynamic header in angular 2 http provider -
i have http interceptor built via tutorial
https://scotch.io/@kashyapmukkamala/using-http-interceptor-with-angular2
the problem need have dynamic header changes automatically once changes 'mode' in app. service able tell interceptor change header, or have interceptor pull header (which string)from service each request. able throwing away patch method, call http.patch('new header string') set header string. call in service controls 'mode' setting. wondering if there way interceptor pull recent value service each request or if can add method http provider via interceptor?
i've tried call service in interceptor each request returns undefined. because creating new instance of service or copying value before service fired , loaded/changed data.
i don't want pass header string every http provider call because defeats purpose of having interceptor, id able set once changes or have provider fetch service before makes request.
tl;dr : need add automatic dynamic header via http interceptor
Comments
Post a Comment