Skip to content

Commit

Permalink
fix(wallstreetcn): crash when article delete (DIYgod#17734)
Browse files Browse the repository at this point in the history
* fix(wallstreetcn): crash when article delete

TypeError: Cannot read properties of undefined (reading 'display_name')

* fix(style): camelCase
  • Loading branch information
defp authored Nov 28, 2024
1 parent 99f77b1 commit 899bd05
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/routes/wallstreetcn/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@ async function handler(ctx) {
url: `${apiRootUrl}/apiv1/content/${item.type === 'live' ? `lives/${item.guid}` : `articles/${item.guid}?extract=0`}`,
});

const data = detailResponse.data.data;
const responseData = detailResponse.data;

// 处理 { code: 60301, message: '内容不存在或已被删除', data: {} }
if (responseData.code !== 20000) {
return null;
}

const data = responseData.data;

item.title = data.title || data.content_text;
item.author = data.source_name ?? data.author.display_name;
Expand All @@ -95,6 +102,8 @@ async function handler(ctx) {
)
);

items = items.filter((item) => item !== null);

return {
title: `华尔街见闻 - 资讯 - ${titles[category]}`,
link: currentUrl,
Expand Down

0 comments on commit 899bd05

Please sign in to comment.