Consuming Medium API - JSON
I have a little problem .. I need to get the data from the Medium API and display it in my Digital Portfolio. But I'm having trouble taking this JSON and displaying it in my components. Could you suggest to me how to solve this?
JSON Example:
https://api.rss2json.com/v1/api.json?rss_url=https://medium.com/feed/@mikaeriohana
NOTE:
My intention is to take the JSON data (title, link and image) and display it in a carousel.
Here is the code to fetch the data using axios get.
Let me know if this helps!! To begin with.
You can use mediumData array to render the details as desired.
Here is the sandbox link for you to quickly get started..
https://codesandbox.io/s/busy-mirzakhani-o62c2?file=/src/App.js:0-635
import React, { useEffect, useState } from "react";
import "./styles.css";
import axios from "axios";
export default function App() {
const [mediumData, setMediumData] = useState([]);
const getData = async () => {
const res = await axios.get(
"https://api.rss2json.com/v1/api.json?rss_url=https://medium.com/feed/@mikaeriohana"
);
console.log(res);
setMediumData(res.data.items);
};
useEffect(() => {
getData();
}, []);
console.log(mediumData);
return (
<div className="App">
<h1>Hello CodeSandbox</h1>
<h2>Start editing to see some magic happen!</h2>
</div>
);
}