Skip to content

Commit 1aac59d

Browse files
committed
Try to fix forum API request
1 parent f0a3ba4 commit 1aac59d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/api/forumAPI.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ dotenv.config();
55
import { ForumTopic } from "../types/ForumWebhookTypes";
66

77
export async function getTopic(id: number): Promise<ForumTopic> {
8-
if (!process.env.FORUM_API_KEY) throw new Error('FORUM_API_KEY is not set in the environment variables.');
9-
const response = await fetch(`https://forums.nexusmods.com/api/forums/topics/${id}?key=${process.env.FORUM_API_KEY}`, {
8+
const APIKEY: string | undefined = process.env.FORUM_API_KEY;
9+
if (!APIKEY || !APIKEY.length) throw new Error('FORUM_API_KEY is not set in the environment variables.');
10+
const response = await fetch(`https://forums.nexusmods.com/api/forums/topics/${id}?key=${APIKEY}`, {
1011
method: 'GET',
1112
headers: {
12-
'Content-Type': 'application/json',
13-
'Authorization': `Bearer ${process.env.FORUM_API_KEY}`,
13+
'Content-Type': 'application/json'
1414
},
1515
});
1616

src/server/forumWebhook.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default async function forumWebhook(req: express.Request<{}, {}, any>, re
3333
.setDescription(`**${title}**\n\n${htmlToText(topic.firstPost.content).substring(0, 2000)}`)
3434
.setTimestamp(new Date(topic.firstPost.date))
3535
.setThumbnail(SUGGESTION_ICON)
36-
.setFooter({text: `Tags: ${topic.tags.join(', ')}`});
36+
.setFooter({text: `Tags: ${topic.tags.length ? topic.tags.join(', ') : '_None_'}`});
3737

3838
const webhookMessage: RESTPostAPIWebhookWithTokenJSONBody = { embeds: [embed.data] };
3939
// Send the embed to the suggestion channel.

0 commit comments

Comments
 (0)