Skip to content

[S4] Add request timeout and standardise error parsing in the API client #800

Description

@Akshola00

Description

The axios instance in lib/api-client.ts has no timeout configured. A hanging request will block the UI indefinitely with no feedback to the user. Additionally, API errors come back in different shapes ({ message }, { error }, plain strings) and each caller handles them differently.

Deliverables

  • Add timeout: 10_000 (10 seconds) to the axios instance configuration in lib/api-client.ts
  • Add a parseApiError(err: unknown): string helper in the same file (or lib/errors.ts) that extracts a human-readable message from any axios error shape
  • The helper should handle:
    • err.response.data.message (NestJS default)
    • err.response.data.error
    • err.message (network/timeout errors)
    • Fallback: 'Something went wrong. Please try again.'
  • All existing callers that catch API errors should use parseApiError
  • npm run build passes

Notes

No new dependencies — this uses only what axios already provides.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EasyFrontendStellar WaveIssues in the Stellar wave programstage-4Frontend-Backend integration

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions