Skip to content

Commit b9d4463

Browse files
committed
fix: error handling for slack post when leetcode api errors
1 parent c9f47e3 commit b9d4463

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

bot.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class LeetCodeBot {
4343
method: 'POST',
4444
headers: {
4545
referer: 'https://leetcode.com/problemset/',
46-
'Content-Type': 'application/json'
46+
'Content-Type': 'application/json',
4747
},
4848
body: `{"query":"${questionOfTheDay}","operationName":"questionOfToday"}`
4949
});
@@ -192,12 +192,12 @@ ${Object.entries(problems.grind75.problems).reduce((acc, [difficulty, problem])
192192
elements: [
193193
{
194194
type: "text",
195-
text: `(${problems.leetcode_daily.difficulty}) `
195+
text: `${problems.leetcode_daily ? `(${problems.leetcode_daily.difficulty})` : 'There was a problem with the Leetcode API\n'}`
196196
},
197197
{
198198
type: "link",
199-
url: `${baseLeetcodeURL}${problems.leetcode_daily.link}`,
200-
text: problems.leetcode_daily.title,
199+
url: `${baseLeetcodeURL}${problems.leetcode_daily ? problems.leetcode_daily.link : '/problemset'}`,
200+
text: problems.leetcode_daily ? problems.leetcode_daily.title : 'Find the daily problem on the calenadar here',
201201
}
202202
]
203203
}

0 commit comments

Comments
 (0)