apple-touch-icon@2.png


I wrote a basic API to parse RSS data from any source (in particular the Washington Post). The route I wrote is simple enough, it just checks what category your looking for, then queries the newest data in that feed. However the program runs slower than I need it to. For reasons explained below, it needs to respond in less that 8s.
I haven’t been a active software developer for years (junior dev for 2 yrs like 15 yrs ago) so I am rusty. I’m new to node js and I have never written an API before.

I’m working on this because I’m trying to integrate it with an online service that requires all api calls to return in under 8s. However, my functions return in about 22s. I switched parsing methods and got it down to about 14s but from here I’m stuck. Does anyone know a quicker way to parse large rss feeds.

I’m using rss parser package ans even switch to fast-xml-parser with not luck.

I don’t even need all 15 or 20 posts, just the latest 3. I tried using trim to limit the results but that doesn’t seem to make any significant difference. Below is the code. I also can link to the repo in github if more context is needed. Any help would be appreciated!

//Basic RSS parser returning array of results.

async function fetchRssFeed(feedUrl) {

    let feed = await.    parser.parseURL(feedUrl);

    return feed.items.map(item => {

        return {

            title: item.title,

            link: item.link,

            date: item.pubDate

        }

    });

}



Source link

By Ajay Kumar Verma

techopenion is the one stop solution of all your information needs. Get everything from latest tech updates to latest gadgets in technology.

Leave a Reply

Your email address will not be published. Required fields are marked *