commit 0ec8fad19a0b0c6df5721ceb03ec2a597aad26aa
parent 3f02ac2409aa8ef3007fd0330a3102f577a79b8f
Author: Ehren Graber <ehren@grabertech.com>
Date: Wed, 18 Jan 2017 02:45:54 -0800
Replace the deprecated Google Api feed RSS to JSON service (#1092)
Diffstat:
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/data/queries/news.js b/src/data/queries/news.js
@@ -12,8 +12,8 @@ import fetch from '../../core/fetch';
import NewsItemType from '../types/NewsItemType';
// React.js News Feed (RSS)
-const url = 'http://ajax.googleapis.com/ajax/services/feed/load' +
- '?v=1.0&num=10&q=https://reactjsnews.com/feed.xml';
+const url = 'https://api.rss2json.com/v1/api.json' +
+ '?rss_url=https%3A%2F%2Freactjsnews.com%2Ffeed.xml';
let items = [];
let lastFetchTask;
@@ -31,8 +31,8 @@ const news = {
lastFetchTask = fetch(url)
.then(response => response.json())
.then(data => {
- if (data.responseStatus === 200) {
- items = data.responseData.feed.entries;
+ if (data.status === 'ok') {
+ items = data.items;
}
return items;
diff --git a/src/data/types/NewsItemType.js b/src/data/types/NewsItemType.js
@@ -19,8 +19,8 @@ const NewsItemType = new ObjectType({
title: { type: new NonNull(StringType) },
link: { type: new NonNull(StringType) },
author: { type: StringType },
- publishedDate: { type: new NonNull(StringType) },
- contentSnippet: { type: StringType },
+ pubDate: { type: new NonNull(StringType) },
+ content: { type: StringType },
},
});
diff --git a/src/routes/home/Home.js b/src/routes/home/Home.js
@@ -16,7 +16,7 @@ class Home extends React.Component {
news: PropTypes.arrayOf(PropTypes.shape({
title: PropTypes.string.isRequired,
link: PropTypes.string.isRequired,
- contentSnippet: PropTypes.string,
+ content: PropTypes.string,
})).isRequired,
};
@@ -31,7 +31,7 @@ class Home extends React.Component {
<a href={item.link} className={s.newsTitle}>{item.title}</a>
<span
className={s.newsDesc}
- dangerouslySetInnerHTML={{ __html: item.contentSnippet }}
+ dangerouslySetInnerHTML={{ __html: item.content.substring(0, 100) }}
/>
</li>
))}
diff --git a/src/routes/home/index.js b/src/routes/home/index.js
@@ -24,7 +24,7 @@ export default {
'Content-Type': 'application/json',
},
body: JSON.stringify({
- query: '{news{title,link,contentSnippet}}',
+ query: '{news{title,link,content}}',
}),
credentials: 'include',
});