Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to parse rss feed on client side in React

Tags:

reactjs

rss

I am trying to parse rss feed in my React application (in componentDidMount). I've looked at multiple js libraries that do this but they all work on the server side. Does anyone know npm packages that work on the client side? Or is it easier for me to write my own function that does the parsing?

like image 915
katya Avatar asked Jun 29 '26 00:06

katya


1 Answers

Using 'rss-parser' as mentioned, this worked for me:

let parser = new Parser();
const CORS_PROXY = "<some cors proxy>";

(async () => {
  let feed = await parser.parseURL(CORS_PROXY + this.props.url);
  feed.items.forEach(item => {
    console.log(item);
  });
})();

npm rss-parser

like image 100
Alexis Rengifo Avatar answered Jun 30 '26 16:06

Alexis Rengifo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!