简体   繁体   中英

How do increase angular request timeout

I have a request take about 2-5 minutes but it always break at 30s
Is there any way to increase request timeout or prevent request was canceled automatically with angular 8.x?

You need to use the timeout operator. Since rxjs 5.5.2 you need to use the pipe method with lettable operators. And assuming you are using the HttpClient to make your requests, there is no need for a map(response => response.json()).

Like this:

import { timeout, catchError } from 'rxjs/operators'; import { of } from 'rxjs/observable/of';

http.get(' https://example.com ').pipe( timeout(2000), catchError(e => { // do something on a timeout return of(null); }) )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM