rss-parser icon indicating copy to clipboard operation
rss-parser copied to clipboard

error in android and ios on run time with React Native

Open mhhonline opened this issue 5 years ago • 2 comments

Greetings,

I am using the lib on react native project. it is working fine on the browser (chrome) on android and ios, it is throwing an error ..

The package at "node_modules/rss-parser/lib/parser.js" attempted to import the Node standard library module "http". It failed because the native React runtime does not include the Node standard library. Read more at https://docs.expo.io/workflow/using-libraries/#using-third-party-libraries

Implementation:

import * as rssParser from 'rss-parser';
....
const fetchRssData = async () => {
    setIsLoading(true);
    // console.log(url);
    // TODO check the best solution https://wanago.io/2018/11/05/cors-cross-origin-resource-sharing/
    const CORS_PROXY = 'https://cors-anywhere.herokuapp.com/';
    let parser = new rssParser();
    (async () => {
      let feed = await parser.parseURL(CORS_PROXY + url);
      // get the title and update the page title
      console.log(feed.items?.length);
      const l = feed.items?.length;

      let data = new Array();
      if (l && l > 0) {
        setData(feed.items);
      }
      setIsLoading(false);
      setIsRefreshing(false);
    })();
  };
"rss-parser": "^3.9.0"

thanks

mhhonline avatar Aug 01 '20 11:08 mhhonline

Greetings,

No input. I need your support

mhhonline avatar Aug 06 '20 08:08 mhhonline

You can try the solutions found here: https://github.com/rbren/rss-parser/issues/53

I don't know enough about native React to be very helpful here.

rbren avatar Aug 06 '20 12:08 rbren