Back
Version 19
8/23/2023
export const newRSSItems = async () => {
const url = "https://www.wired.com/feed/category/business/latest/rss";
const lastRunAt = 1692218195127;
const data = await me.fetchRSS(url);
let entriesOrItems = [];
return data;
if (!data) {
throw new Error("Failed to fetch feed");
}
if (data.channel) {
entriesOrItems = data.channel.item;
}
else if (data.feed) {
entriesOrItems = data.feed.entry;
}
else {
throw new Error("Unsupported feed format.");
}
return entriesOrItems.filter(({ pubDate, published }) => {
const dateToCheck = pubDate || published;
return lastRunAt && new Date(dateToCheck) > new Date(lastRunAt);
});
};
// Forked from @stevekrouse.newRSSItems
Updated: October 23, 2023