I'm working with the Twitter API and I'm trying to get only the first news of a tweet and its link. If I console.log
tweetNews
I get something like this as example:
{
text: 'exampletext. \n' +
'\n' +
'exampletext. \n' +
'\n' +
'https://examplelink',
href: 'https://examplelink
},
I would like to get only the first string of the text
, removing also the link inside the text
.
Down below the rest of my code:
module.exports.filterTweets = (parsedArray) => {
const filteredTweets = parsedArray.filter(
(tweet) => tweet.entities.urls.length === 1
);
const tweetNews = filteredTweets.map((x) => {
return { text: x.full_text, href: x.entities.urls[0].url };
});
console.log("tweetNews", tweetNews);
return tweetNews;
};