我想为我的整个Angular 4应用程序使用相同的请求选项。特别是我想通过withCredentials: environment.xhrWithCredentials
请求(基于当前环境)。Angular 4如何为整个应用程序设置HttpClient的默认选项?
但我不认为这是一个好主意,为每个设置选项,这样每一个请求:
this.http.get('/api', {withCredentials: environment.xhrWithCredentials})
有没有办法为整个应用程序设置默认选项为HttpClient
一次?
你能想到的采用了棱角分明httpInterceptor参考[本条](https://medium.com/aviabird/http-interceptor-angular2-way-e57dc2842462) –
嗯..你总是可以覆盖默认的HTTP实现的。 – Arun
@Injectable() export class HttpInfraAPIService extends Http {....} – Arun