Skip to content

fix: use apiRequest and API_CONFIG in usePortfolio hook - #73

Open
TCROWN10 wants to merge 1 commit into
grantFoxin:mainfrom
TCROWN10:fix/use-portfolio-api-request
Open

fix: use apiRequest and API_CONFIG in usePortfolio hook#73
TCROWN10 wants to merge 1 commit into
grantFoxin:mainfrom
TCROWN10:fix/use-portfolio-api-request

Conversation

@TCROWN10

Copy link
Copy Markdown

Summary

  • Route usePortfolio through apiRequest and API_CONFIG so portfolio fetch/rebalance hit the configured API origin instead of relative /api/... paths
  • Pick up retry (3 attempts with backoff), 15s timeout, and JSON error parsing from the shared client
  • Keep setPortfolio(data.portfolio) aligned with { success: true, portfolio } from GET /api/portfolio/:id

Closes #66

Test plan

  • Frontend npm run build (tsc && vite build) succeeds
  • Loading a portfolio with VITE_API_URL set to a remote origin calls that host, not the frontend origin
  • Failed network requests surface hook error and retry per apiRequest
  • Successful rebalance refreshes portfolio from parsed JSON

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: usePortfolio hook uses relative API paths and bypasses retry/timeout logic

1 participant