fix:#150 fixed return

This commit is contained in:
Elmar Kresse
2024-01-21 18:51:02 +01:00
parent fbf99de175
commit 32c6f962d5
2 changed files with 10 additions and 4 deletions

View File

@@ -23,18 +23,22 @@ func GetRooms(app *pocketbase.PocketBase) ([]string, error) {
return nil, err
}
roomArray := clearAndSeparateRooms([]struct {
roomArray, err := clearAndSeparateRooms([]struct {
Rooms string
Course string
}(events))
return roomArray
if err != nil {
return nil, err
}
return roomArray, nil
}
func clearAndSeparateRooms(events []struct {
Rooms string
Course string
}) []string {
}) ([]string, error) {
var roomArray []string
for _, event := range events {

View File

@@ -3,6 +3,7 @@ package room
import (
"htwkalender/model"
"htwkalender/service/db"
"log/slog"
"net/http"
"github.com/labstack/echo/v5"
@@ -13,7 +14,8 @@ func GetRooms(c echo.Context, app *pocketbase.PocketBase) error {
rooms, err := db.GetRooms(app)
if err != nil {
return c.JSON(http.StatusNotFound, err)
slog.Error("Error getting rooms: ", err)
return c.JSON(http.StatusNotFound, "No rooms found")
} else {
return c.JSON(http.StatusOK, rooms)
}