fix crash on 500 error in getMessageAuthor

This commit is contained in:
Akinwale Ariwodola 2017-12-07 09:43:08 +01:00
parent 68494c66b7
commit adc253045b

5
app.js
View file

@ -533,6 +533,11 @@ const getMessageAuthor = (thingId, accessToken, callback) => {
return callback(e, null);
}
// possible 500 error
if (!response || !response.data || !response.data.children) {
return callback(new Error('Could not retrieve the message author info.'), null);
}
return callback(null, (response.data.children.length > 0) ? response.data.children[0].data.author : null);
});
};