Skip to content

Commit

Permalink
Ensure channels response is always an array in the frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Satish Surath committed Feb 8, 2025
1 parent 57483ec commit c65b604
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ document.addEventListener("DOMContentLoaded", () => {
try {
const res = await fetch("/api/channels");
const channels = await res.json();
// If channels is not an array (e.g., a single object), convert it to an array
if (!Array.isArray(channels)) {
channels = [channels];
}
if (!Array.isArray(channels) || channels.length === 0) {
channelList.innerText = "No channels found.";
return;
Expand Down

0 comments on commit c65b604

Please sign in to comment.