1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { untitled_blackCrayfish } from "https://esm.town/v/stevekrouse/untitled_blackCrayfish?v=1";
async function processFeed() {
let rssData = await untitled_blackCrayfish; // Line 1
console.log("Keys of rssData.rss:", Object.keys(rssData.rss)); // Log the keys of rssData.rss
// console.log("Keys of rssData.rss.channel:", Object.keys(rssData.rss.channel)); // Log the keys of rssData.rss.channel
// console.log("First item:", rssData.rss.channel.item[0]); // Log the first item
for (let item of rssData.rss.channel.item) {
console.log("link:", item.link);
}
let links = []; // Line 2
for (let i = 0; i < rssData.length; i++) { // Line 3
console.log(rssData[i]); // Add this line
if (rssData[i].link) { // Check if the item has a link property
console.log(rssData[i]); // Add this line
links.push(rssData[i].link); // If it does, push it into the links array
}
}
return links; // Line 5
}
processFeed().then(output => console.log(output)); // Call the function and print the output to the console
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
December 14, 2023