我有一个看起来像这样的请求:
private getData(param) {
const url = (name: string) =>
`https://website.com/${name}/data`;
return this.http.get<Data>(url(param));
}
当请求返回错误时,我想重试但使用另一个参数。你怎么能那样做?
我能够捕捉到这样的错误
private getData(param) {
const url = (name: string) =>
`https://website.com/${name}/data`;
return this.http.get<Data>(url(param)).pipe(
catchError(error => of(error))
);
}
但是您将如何使用不同的 url 重试?