err := json.NewDecoder(r.Body).Decode(&assignedSongKeys)
if err != nil {
+ // https://stackoverflow.com/questions/67140505/http-superfluous-response-writeheader-call
w.WriteHeader(http.StatusInternalServerError)
+ w.Write([]byte("Failed to parse JSON: " + err.Error()))
return
}
c, err := dbw.RedisDb.ZCount(dbw.Ctx, name, "-inf", "+inf").Result()
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
+ w.Write([]byte("Failed to count entries on name: " + err.Error()))
return
}
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
+ w.Write([]byte("Failed to complete ZAdd command: " + err.Error()))
return
}
}
<body>
+ <a href="/rooms.html">Room Management</a>
<div id="outerSongList">
<h1><u>Song List</u></h1>
+/**
+ * ROOM CREATION
+ **/
+
+let createRoomButton = document.getElementById("createRoomButton")
+
+
+async function createRoomWithName() {
+ let name = prompt("Name the room")
+
+ let response = await fetch("/api/rooms/add/" + name, {
+ method: "PUT",
+ body: JSON.stringify(["0"])
+ })
+
+ if (response.status != 200) {
+ alert(await response.text())
+ return
+ }
+
+ populateRoomSelect()
+}
+
+createRoomButton.addEventListener("click", (_) => { createRoomWithName() } )
+
/**
* ADD / REMOVE FROM ROOMS
**/
</head>
<body>
+ <a href="/">Home</a>
+ <button id="createRoomButton">Make a New Room</button>
<label for="rooms">Select a Room to View</label>
<select name="rooms" id="roomSelect">