Reputation: 397
I have an API
that in development environment takes more than 1 minute
to return, however, always timeout in 60s
, how can I change the timeout
default (by postman
, it returns normally, even if it takes more than 1 min, so it is not a backend )?
I tried a solution I found on the internet, however, with values less than 60s it works, but even putting a high value, timeout when it hits 60s
.
@Injectable()
export class TimeoutInterceptor implements HttpInterceptor {
constructor(@Inject(DEFAULT_TIMEOUT) protected defaultTimeout: number) {
}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(req).pipe(timeout(300000));
}
}
Upvotes: 0
Views: 335
Reputation: 12036
try this:
@NgMoule({
....
imports: [HttpClientModule],
providers: [{provide: DEFAULT_TIMEOUT, useValue: 180*1000}] <- should be provided in the same module where you already have HttpClientModule
})
export class AppModule {...
Upvotes: 1