From 277fa04be3f96b1c7a8f84e7bd0f5ab71d6cf179 Mon Sep 17 00:00:00 2001 From: Fatpandac <1779196284@qq.com> Date: Fri, 11 Feb 2022 20:46:41 +0800 Subject: [PATCH] fix(route): wallstreetcn/live some data have not author property (#9073) --- lib/v2/wallstreetcn/live.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/v2/wallstreetcn/live.js b/lib/v2/wallstreetcn/live.js index ef0b237708..4ba58d62e7 100644 --- a/lib/v2/wallstreetcn/live.js +++ b/lib/v2/wallstreetcn/live.js @@ -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]} - 实时快讯 - 华尔街见闻`,