From 98b29ff58bd36cce424f6932fbc1a29931acc5e0 Mon Sep 17 00:00:00 2001 From: GitHub Copilot Date: Wed, 23 Apr 2025 21:33:53 -0400 Subject: [PATCH] #1 Update index.astro to fetch accounts from API endpoint --- src/pages/index.astro | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/index.astro b/src/pages/index.astro index 19b86f1..dcf9acd 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -5,12 +5,12 @@ import MainContent from '../components/MainContent.astro'; import type { Account, Transaction } from '../types'; import { formatCurrency, formatDate } from '../utils'; -// Initialize with empty arrays until API integration -const accounts: Account[] = []; -const allTransactions: Transaction[] = []; +// Fetch accounts from API +const accountsResponse = await fetch('http://localhost:4321/api/accounts'); +const accounts: Account[] = await accountsResponse.json(); -// Create an empty initial account -const initialAccount: Account = { +// Initialize with first account or empty account if none exist +const initialAccount: Account = accounts[0] || { id: '', name: 'No accounts available', last4: '0000', @@ -25,7 +25,7 @@ const initialTransactions: Transaction[] = []; -