Medium does not offer an API to retrieve your medium stories.
Luckily https://medium.com/@jalalio/latest?format=json returns json.
The problems:
- Medium prevents JSON hacking by putting this string in the beginning of the json
])}while(1);</x>
- They don't allow cross domain calls so our AJAX response gets rejected in the browser
The solution: A firebase function which fetches the medium URL and returns a nice JSON string.
Create a new project or add later to an existing one. https://console.firebase.google.com
npm install -g firebase-tools
git clone https://github.com/JaySunSyn/medium-firebase-proxy
cd medium-firebase-proxy
open functions/index.js
replace YOUR_MEDIUM_USERNAME
with your actual username
open .firebaserc
replace YOUR_FIREBASE_PROJECT_ID
with your project id
firebase deploy
go to https://console.firebase.google.com/u/0/project/YOUR_FIREBASE_PROJECT_ID/functions/list
copy the URL listed under the medium
function.
e.g. https://us-central1-my-app.cloudfunctions.net/medium
e.g. in the medium-stories-element