From 58078a761eca8a4701c7da5ed2dab1a3081a8be2 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Fri, 15 Jun 2018 14:29:09 +0800 Subject: [PATCH] fix JSON.parse empty --- routes/3dm/news.js | 4 ++-- routes/3dm/news_center.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/routes/3dm/news.js b/routes/3dm/news.js index 75d9c3029..a4ec7ac1f 100644 --- a/routes/3dm/news.js +++ b/routes/3dm/news.js @@ -29,9 +29,9 @@ module.exports = async (ctx) => { const urlBase = url.replace(/.html/, ''); let total = 1; - const value = JSON.parse(await ctx.cache.get(url)); + const value = await ctx.cache.get(url); if (value) { - item = value; + item = JSON.parse(value); } else { // ๆŠ“ๅ–ๅˆ†้กต for (let j = 1; ; j++) { diff --git a/routes/3dm/news_center.js b/routes/3dm/news_center.js index 2cf4e8f1f..8ae8bbbbd 100644 --- a/routes/3dm/news_center.js +++ b/routes/3dm/news_center.js @@ -23,9 +23,9 @@ module.exports = async (ctx) => { const itemUrl = $(item) .find('a:nth-child(2)') .attr('href'); - const cache = JSON.parse(await ctx.cache.get(itemUrl)); + const cache = await ctx.cache.get(itemUrl); if (cache) { - out.push(cache); + out.push(JSON.parse(cache)); continue; } const title = $(item)