Turn any Medium feed into a JSON object you can consume on your own site.
- Clone this repo
- Install dependencies by running
npm install
- Start the serer by running
npm start
- Open your favorite API client (Postman or Insomnia for instance) or just open up a browser tab to make a GET request to 'http://localhost:8081/api/medium-posts/<MEDIUM_USERNAME>' to fetch the posts from a specific Medium user.
To use this in your own application, just install the rss-to-json
package:
npm install rss-to-json
And adapt the following logic from the endpoint to your needs:
import { parse } from 'rss-to-json'
const fetchPosts = async (username) => {
const getFeed = async () => {
let rss = await parse(`https://medium.com/feed/@${username}`)
return JSON.stringify(rss, null, 3)
}
const json = await getFeed()
const posts = JSON.parse(json).items
return posts
}
Enjoy!
Credit: This project is using the rss-to-json library.