My get request of one BACKEND API i am calling is getting more than 2 minutes.And i am trying to handle this using Angular Http Interceptors.When i added "timeout": 360000
in proxy.config my problem solved to some extent.But still sometimes it fails. This is my Interceptor class.
export const DEFAULT_TIMEOUT = new InjectionToken<number>('defaultTimeout');
@Injectable()
export class DashboardInterceptor implements HttpInterceptor {
constructor(@Inject(DEFAULT_TIMEOUT) protected defaultTimeout: number) {
}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
const timeoutValue = req.headers.get('timeout') || this.defaultTimeout;
const timeoutValueNumeric = Number(timeoutValue);
return next.handle(req).pipe(timeout(timeoutValueNumeric));
}
}
Since it fails i am trying to send headers in the call.But it does n't allow.
getInfo(headers: new HttpHeaders({ timeout: `${360000}` }), params: any[]) {
return this.apiService.get(environment.rm_url + 'rm-analytics-api/dashboard/txn-info', headers, params).pipe(
timeout(360000),
catchError(error => {
console.log('Response error!');
return of({ error});
}
));
}
And i added this to dashboard.module.ts
providers:[ [DashboardServiceHandler, [{ provide: HTTP_INTERCEPTORS, useClass: DashboardInterceptor, multi: true }],
[{ provide: DEFAULT_TIMEOUT, useValue: 360000 }]]
And I added this to proxy.config as well.
"secure": false,
"timeout": 360000,
How could i solve this problem?