Closed matiasfha closed 1 year ago
+1
Anyone going to merge this?
I've tried to keep the dependencies here down to a minimum--especially important for running in the browser. I'm hesitant to include this.
I would encourage you to use fetch
to get the RSS XML, and then use this package's parseString
--that should get around the issue.
Isn’t fetch available on node, browser and edge runtimes now? That means that i can get rid of isomorphic-fetch
Hmm it does seem to have pretty solid browser support according to https://caniuse.com/fetch
I wonder if we can:
fetch
is availableWDYT?
I tried to do this, and got:
./node_modules/rss-parser/lib/parser.js:6:12-26 - Error: Module not found: Error: Can't resolve 'url' in '
Here is my code:
parseUrlWrapper()
{
return new Promise<Parser.Output<Parser.Item>>((resolve,reject)=> {
let p : Parser = new Parser({
customFields: {
item: ['image']
}
});
fetch(this.targetUrl).then(response => {
response.json().then(data => {
p.parseString(data, function(err : Error, feed: Parser.Output<Parser.Item>) {
if (err) {
reject(err);
} else {
resolve(feed);
}
});
});
});
});
}
It looks like the pull request removed a lot of these dependencies - I had done my own pull request on this branch, and was using it unmerged - it looks like I'll need to go back to that since it still depends upon URL, Https, etc.
This proved to be correct, it is now working. the code above seems to work based on the advice given!
The idea is to remove the usage of
http
andhttps
package that are node dependent and instead useisomorphic-fetch
to allow the parser to work on edge environments where the node packages can't run.