A step-by-step tutorial on how to implement an RSS feed from JSON by converting it to XML and creating a static page in Gatsby πŸš€

Photo by Cookie the Pom on Unsplash

I

mplementing a site-wide RSS feed in Gatsby can be done very easily. I can recommend implementing the official Gatsby feed plugin.

In this tutorial, I want to show you how you can implement an RSS feed for a specific URL or page. In my case, the data for the RSS feed was provided to me via a REST API endpoint that returned JSON.

πŸ’‘This tutorial assumes you already have a Gatsby site setup and running. If you are new to Gatsby, I can highly recommend the Gatsby docs to get started.

Here are the steps that I am going to walk you through in detail in this tutorial:

β€” Test your API endpoint with Postman

β€” Call JSON in /gatsby-node.js with Axios

β€” Shape JSON by turning it into a JavaScript Object

β€” Convert the new object to RSS XML with jstoxml

β€” Use fs from Node.js to create a new file rss.xml

β€” Test your new RSS feed with an RSS validator

Without further ado, let’s get started πŸ™Œ

The first step is to call the API endpoint and make sure that it returns the correct JSON. Postman is an excellent tool to test your REST API endpoint.


It is as easy as creating a new β€˜GET’ Request and inserting the endpoint. If your endpoint requires authentication you can read more about how to authenticate in Postman in the Postman Learning Center.

Image of GET Request to API endpoint returning JSON in Postman Client

#nodejs #api #rss #xml #json

Implement an RSS feed from JSON to XML in Gatsby.js
9.90 GEEK