diff options
author | 2018-06-27 14:33:34 +0300 | |
---|---|---|
committer | 2023-01-13 10:37:53 +0300 | |
commit | 40b8cd9853dd87deb90afdda0f5af78faa414f2b (patch) | |
tree | f4beb12efd422f178cfe168367ef91b17f6131b8 /vnext/src/components/Feeds.js | |
parent | 8307e220c4fdddbc0a9740ad4b43fc2e205864bd (diff) |
fetch -> axios
Diffstat (limited to 'vnext/src/components/Feeds.js')
-rw-r--r-- | vnext/src/components/Feeds.js | 15 |
1 files changed, 6 insertions, 9 deletions
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 (<Feed authRequired="true" query={query} {...props} />) @@ -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(); |