Hello,
I want to configure two instances of aurelia-http-client to access information from different servers (backend API and Azure Table Storage). At the moment I have only the backend API instance configured on the Aurelia Container through dependency injection which is used everywhere in the application to access the data. I need to configure a second instance with authorization to be able to query Azure Table Storage.
Current configuration in App.ts
public httpClient: HttpClient;
constructor() {
container = Container.instance;
this.configureHttpContainer(au.container, apiUrl);
}
activate() {
let container = Container.instance;
}
public configureHttpContainer(container: Container, apiUrl: string): void {
let http = new HttpClient();
let self = this;
http.configure(config => {
config
.withBaseUrl(apiUrl)
.withInterceptor({
request(request: RequestMessage): RequestMessage {
request.headers.add('Authorization', 'Bearer ')
return request;
},
response(response: HttpResponseMessage): HttpResponseMessage {
return response;
},
responseError(error: HttpResponseMessage): HttpResponseMessage {
return error;
},
});
});
container.registerInstance(HttpClient, http);
this.httpClient = http;
}
How can I achieve that?