I have been trying to upload a CSV file using an HttpInterceptor as a middleware. Everything works fine for normal requests, but I need to modify the request header to 'multipart/data' specifically for CSV uploads.
Below is the code snippet:
export class NoopInterceptorService implements HttpInterceptor {
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
let token = this._tokenManagerService.getToken();
const newRequest = request.clone({
setHeaders: {
'Content-Type': 'application/json',
'Authorization': `${token}`
}
});
return next.handle(newRequest);
}
}
I would appreciate any suggestions on how to achieve this.