diff --git a/src/services/ProfileService.ts b/src/services/ProfileService.ts index 8f8abcdc..3ec64edd 100644 --- a/src/services/ProfileService.ts +++ b/src/services/ProfileService.ts @@ -261,13 +261,31 @@ export class ProfileService { if (this.isAxiosError(error)) { return error.config?.url; } - if (this.isApiError(error) && (error as any).config) { - const config = (error as any).config as { url?: string }; - return config.url; + if (this.isApiError(error) && this.hasConfigProperty(error)) { + const config = this.getConfigProperty(error); + return config?.url; } return undefined; } + /** + * Type guard to check if error has config property + */ + private hasConfigProperty( + error: unknown, + ): error is { config?: { url?: string } } { + return typeof error === "object" && error !== null && "config" in error; + } + + /** + * Safely extract config property from error + */ + private getConfigProperty(error: { + config?: { url?: string }; + }): { url?: string } | undefined { + return error.config; + } + /** * Type guard for AxiosError */