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:
Sonu Kapoor 2020-09-28 17:56:57 +03:00 committed by Alex Rickabaugh
parent c74917a7d5
commit 5ef2c983b9
1 changed files with 1 additions and 1 deletions

View File

@ -8,13 +8,13 @@ import { ajax } from 'rxjs/ajax';
import { map, retry, catchError } from 'rxjs/operators';
const apiData = ajax('/api/data').pipe(
retry(3), // Retry up to 3 times before failing
map(res => {
if (!res.response) {
throw new Error('Value expected!');
}
return res.response;
}),
retry(3), // Retry up to 3 times before failing
catchError(err => of([]))
);