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 and pull[bot] committed Nov 28, 2024
1 parent ac4e63c commit 5a089cd
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 5a089cd

Please sign in to comment.