fix an issue where post has images but resolutions array is undefined

This commit is contained in:
teddit 2020-11-19 06:50:51 +01:00
parent 9665f36681
commit e4e5136b37
1 changed files with 4 additions and 2 deletions

View File

@ -45,11 +45,13 @@ module.exports = function() {
thumb: await downloadAndSave(data.thumbnail, 'thumb_') thumb: await downloadAndSave(data.thumbnail, 'thumb_')
} }
} else { } else {
if(data.preview.images[0].resolutions[0]) {
images = { images = {
thumb: await downloadAndSave(data.preview.images[0].resolutions[0].url, 'thumb_') thumb: await downloadAndSave(data.preview.images[0].resolutions[0].url, 'thumb_')
} }
} }
} }
}
let obj = { let obj = {
author: data.author, author: data.author,
created: data.created_utc, created: data.created_utc,