Skip to content

Commit

Permalink
Fix tweets plugin when includes is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
lowlighter committed Mar 30, 2021
1 parent addefee commit 190dd39
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion source/plugins/tweets/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

//Load tweets
console.debug(`metrics/compute/${login}/plugins > tweets > querying api`)
const {data:{data:tweets = [], includes:{media = []}}} = await imports.axios.get(`https://api.twitter.com/2/tweets/search/recent?query=from:${username}&tweet.fields=created_at,entities&media.fields=preview_image_url,url,type&expansions=entities.mentions.username,attachments.media_keys`, {headers:{Authorization:`Bearer ${token}`}})
const {data:{data:tweets = [], includes:{media = []} = {}}} = await imports.axios.get(`https://api.twitter.com/2/tweets/search/recent?query=from:${username}&tweet.fields=created_at,entities&media.fields=preview_image_url,url,type&expansions=entities.mentions.username,attachments.media_keys`, {headers:{Authorization:`Bearer ${token}`}})
const medias = new Map(media.map(({media_key, type, url, preview_image_url}) => [media_key, (type === "photo")||(type === "animated_gif") ? url : type === "video" ? preview_image_url : null]))

//Limit tweets
Expand Down

0 comments on commit 190dd39

Please sign in to comment.