From 40b8cd9853dd87deb90afdda0f5af78faa414f2b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 27 Jun 2018 14:33:34 +0300 Subject: fetch -> axios --- vnext/src/components/Feeds.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'vnext/src/components/Feeds.js') diff --git a/vnext/src/components/Feeds.js b/vnext/src/components/Feeds.js index 5e9c14d0..0a27ed3d 100644 --- a/vnext/src/components/Feeds.js +++ b/vnext/src/components/Feeds.js @@ -7,6 +7,8 @@ import moment from 'moment'; import Message from './Message'; import Spinner from './Spinner'; +import { getMessages } from '../api'; + export function Discover(props) { const query = { baseUrl: "https://api.juick.com/messages", @@ -38,7 +40,7 @@ export function Blog(props) { export function Tag(props) { const { tag } = props.match.params; const query = { - baseUrl: `https://api.juick.com/messages`, + baseUrl: '/messages', search: { tag: tag }, @@ -49,7 +51,7 @@ export function Tag(props) { export function Home(props) { const query = { - baseUrl: `https://api.juick.com/home`, + baseUrl: '/home', pageParam: 'before_mid' }; return () @@ -81,17 +83,12 @@ class Feed extends React.Component { if (hash) { params.hash = hash; } - if (Object.keys(params).length > 0) { - url = `${url}?${qs.stringify(params)}`; - } if (!params.hash && this.props.authRequired) { this.props.history.push('/') } - fetch(url) + getMessages(url, params) .then(response => { - return response.json() - }) - .then(data => { + const { data } = response; const { pageParam } = this.props.query; const lastMessage = data.slice(-1)[0] || {}; const pageValue = pageParam === 'before_mid' ? lastMessage.mid : moment.utc(lastMessage.updated).valueOf(); -- cgit v1.2.3