Transactions
15 min read
Send a New Transaction to the API
Add addTransaction() to client/src/lib/api.js and call it from the form submit handler.
Send the same fields the server expects and use await so the UI only clears the form after a successful response.
const created = await api.addTransaction(entry);
setTransactions((prev) => [...prev, created]);
Test it
Add a small expense, refresh the page, and confirm it remains. That proves the request reached the server and was persisted.
Checkpoint
Creating a transaction updates the UI and survives a page refresh.