fix(docs-infra): fix the retry-on-error example (#38905)
Previously, the `retry` example did not work as intended. The `retry` operator was called before the exception occured, thus not retrying the `ajax` request. This commit moves the `retry` operator into the correct order to ensure that the failed request is retried. PR Close #38905
This commit is contained in:
parent
c74917a7d5
commit
5ef2c983b9
|
@ -8,13 +8,13 @@ import { ajax } from 'rxjs/ajax';
|
||||||
import { map, retry, catchError } from 'rxjs/operators';
|
import { map, retry, catchError } from 'rxjs/operators';
|
||||||
|
|
||||||
const apiData = ajax('/api/data').pipe(
|
const apiData = ajax('/api/data').pipe(
|
||||||
retry(3), // Retry up to 3 times before failing
|
|
||||||
map(res => {
|
map(res => {
|
||||||
if (!res.response) {
|
if (!res.response) {
|
||||||
throw new Error('Value expected!');
|
throw new Error('Value expected!');
|
||||||
}
|
}
|
||||||
return res.response;
|
return res.response;
|
||||||
}),
|
}),
|
||||||
|
retry(3), // Retry up to 3 times before failing
|
||||||
catchError(err => of([]))
|
catchError(err => of([]))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue