better trade endpoints

This commit is contained in:
samantha42
2026-03-25 22:17:19 +01:00
parent d491b9c14c
commit ff7b41e2a8
7 changed files with 51 additions and 26 deletions

View File

@@ -26,7 +26,7 @@ func AddTradeHandler(db *sql.DB) http.HandlerFunc {
}
// check if currency is in the db.
currency, err := database.GetCurrencyByCode(db, req.Currency)
currency, err := database.GetCurrencyByCode(db, req.CurrencyCode)
if err != nil {
http.Error(w, fmt.Sprintf("failed to find currency: %s", err), http.StatusInternalServerError)
return
@@ -57,7 +57,7 @@ func GetTradeListHandler(db *sql.DB) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
tradeList, err := database.GetTrades(db)
if err != nil {
http.Error(w, fmt.Sprintf("failed to fetch trades:", err), http.StatusInternalServerError)
http.Error(w, fmt.Sprintf("failed to fetch trades: %s", err), http.StatusInternalServerError)
return
}