I am doing this for learning purpose. I have url to RSS feed that I'd like to work further. This feed contains too much information. I'm interested only in all "item", their "title", "description" and "pubDate". I am using "firebase deploy --only functions" and then checking url for deployment where I expect to see cleaned data. For some reason I am getting error in cloud functions logs: "TypeError: Cannot read property 'channel' of undefined at cleanUp (/user_code/lib/index.js:19:29)"
I tried this with another URL which surprisingly worked: https://www.theguardian.com/uk/london/rss
Here is the URL to RSS feed I want to use: https://polisen.se/aktuellt/rss/hela-landet/handelser-i-hela-landet/
Here is my cleanUp function:
function cleanUp(data) {
const items = []
const channel = data.rss.channel
channel.item.forEach(element => {
items.push({
title: element.title,
description: element.description,
date: element.pubDate
})
});
return items
}
I expect to see all items with children title, description and pubdate after deployment. Instead I get "Error: could not handle the request" and when I check my logs in google cloud functions I see:
"TypeError: Cannot read property 'channel' of undefined at cleanUp (/user_code/lib/index.js:19:29)"