From e4e5136b3739756df0bd30c817bdccc39dcc27cc Mon Sep 17 00:00:00 2001 From: teddit Date: Thu, 19 Nov 2020 06:50:51 +0100 Subject: [PATCH] fix an issue where post has images but resolutions array is undefined --- inc/processJsonSubreddit.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/inc/processJsonSubreddit.js b/inc/processJsonSubreddit.js index 95a3e49..c3df10c 100644 --- a/inc/processJsonSubreddit.js +++ b/inc/processJsonSubreddit.js @@ -45,8 +45,10 @@ module.exports = function() { thumb: await downloadAndSave(data.thumbnail, 'thumb_') } } else { - images = { - thumb: await downloadAndSave(data.preview.images[0].resolutions[0].url, 'thumb_') + if(data.preview.images[0].resolutions[0]) { + images = { + thumb: await downloadAndSave(data.preview.images[0].resolutions[0].url, 'thumb_') + } } } }