Skip to content

Instantly share code, notes, and snippets.

@7kfpun
Last active January 13, 2017 06:28
Show Gist options
  • Save 7kfpun/8bce16e3d0c28b2b5c88b7aee3b93192 to your computer and use it in GitHub Desktop.
Save 7kfpun/8bce16e3d0c28b2b5c88b7aee3b93192 to your computer and use it in GitHub Desktop.
Convert RSS to JSON (Google Feed and Yahoo Feed)
// This API is officially deprecated and will stop working after December 15th, 2016.
// const RSS = (url) => {
// const GOOGLE_FEED_API_URL = `https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=-1&q=${encodeURIComponent(url)}`;
// return fetch(GOOGLE_FEED_API_URL).then(res => res.json()); // eslint-disable-line no-undef
// };
const RSS = (url) => {
const YAHOO_FEED_API_URL = `https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20feed%20where%20url%3D%27${encodeURIComponent(url)}%27&format=json&diagnostics=true&callback=`;
return fetch(YAHOO_FEED_API_URL).then(res => res.json());
};
export default RSS;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment