fix(route): wallstreetcn/live some data have not author property (#9073)

This commit is contained in:
Fatpandac
2022-02-11 20:46:41 +08:00
committed by GitHub
parent 4fbe648dde
commit 277fa04be3
+16 -7
View File
@@ -24,13 +24,22 @@ module.exports = async (ctx) => {
url: apiUrl,
});
const items = response.data.data.items.map((item) => ({
link: item.uri,
title: item.title || item.content_text,
description: item.content,
pubDate: parseDate(item.display_time * 1000),
author: item.author.display_name,
}));
const items = response.data.data.items.map((item) => {
let author;
try {
author = item.author.display_name;
} catch (e) {
author = '';
}
return {
link: item.uri,
title: item.title || item.content_text,
description: item.content,
pubDate: parseDate(item.display_time * 1000),
author,
};
});
ctx.state.data = {
title: `${titles[category]} - 实时快讯 - 华尔街见闻`,