Skip to content

Commit

Permalink
fix: handle missing topics in forum response
Browse files Browse the repository at this point in the history
  • Loading branch information
barmac authored May 7, 2024
1 parent ef0ccc6 commit d2bb832
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/api/forum.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export async function getForumReport({ baseUrl }) {
throw new Error(`Failed to fetch forum data: ${res.statusText}`);
}

const ra = await res.json();
const parsed = await res.json();

const report = {
topics: ra.topics.map(topic => ({
topics: (parsed.topics || []).map(topic => ({
id: topic.id,
title: topic.title,
url: getTopicUrl(baseUrl, topic)
Expand Down
4 changes: 1 addition & 3 deletions test/fixtures/forum/empty.json
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"topics": []
}
{}

0 comments on commit d2bb832

Please sign in to comment.