Skip to content
This repository has been archived by the owner on Jul 13, 2020. It is now read-only.

Commit

Permalink
updated data formatting from server to client
Browse files Browse the repository at this point in the history
  • Loading branch information
the-robot committed Feb 18, 2020
1 parent 653d606 commit c21db87
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/web/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const express = require('express');
const moment = require('moment');
const router = express.Router();

const utils = require('../views/utils');
Expand Down Expand Up @@ -58,7 +57,7 @@ router.get(`${routes.api.news}:page/`, async (req, res, next) => {
title: newsData[i].title,
link: newsData[i].link,
author: newsData[i].articleSource.name,
date: moment(newsData[i].isoDate).format('DD-MM-YYYY HH:mm'),
date: newsData[i].isoDate,
});
}

Expand Down Expand Up @@ -86,7 +85,7 @@ router.get(`${routes.api.reddit}:page/`, async (req, res, next) => {
title: redditPostsData[i].title,
link: redditPostsData[i].link,
author: redditPostsData[i].articleSource.name,
date: moment(redditPostsData[i].isoDate).format('DD-MM-YYYY HH:mm'),
date: redditPostsData[i].isoDate,
});
}

Expand Down Expand Up @@ -114,7 +113,7 @@ router.get(`${routes.api.tweets}:page/`, async (req, res, next) => {
title: tweetsData[i].title,
link: tweetsData[i].link,
author: tweetsData[i].articleSource.name,
date: moment(tweetsData[i].isoDate).format('DD-MM-YYYY HH:mm'),
date: tweetsData[i].isoDate,
});
}

Expand Down
6 changes: 6 additions & 0 deletions src/web/views/dynamic/News/NewsFeed.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ButtonToolbar, Icon, IconButton, Timeline } from 'rsuite';
import React from 'react';
import axios from 'axios';
import moment from 'moment';

import routes from '../../../routes/urls';

Expand Down Expand Up @@ -61,6 +62,11 @@ class NewsFeed extends React.Component {
axios.get(`${routes.api.news}${page}`)
.then(res => {
const { data, page, total_pages } = res.data;
// format date data
for (let i=0; i<data.length; i++) {
data[i].date = moment(data[i].date).format('DD-MM-YYYY HH:mm');
}

this.setState({
data,
page,
Expand Down
6 changes: 6 additions & 0 deletions src/web/views/dynamic/News/Reddit.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ButtonToolbar, Icon, IconButton, Timeline } from 'rsuite';
import React from 'react';
import axios from 'axios';
import moment from 'moment';

import routes from '../../../routes/urls';

Expand Down Expand Up @@ -62,6 +63,11 @@ class Reddit extends React.Component {
axios.get(`${routes.api.reddit}${page}`)
.then(res => {
const { data, page, total_pages } = res.data;
// format date data
for (let i=0; i<data.length; i++) {
data[i].date = moment(data[i].date).format('DD-MM-YYYY HH:mm');
}

this.setState({
data,
page,
Expand Down
6 changes: 6 additions & 0 deletions src/web/views/dynamic/News/Tweets.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ButtonToolbar, Icon, IconButton, Timeline } from 'rsuite';
import React from 'react';
import axios from 'axios';
import moment from 'moment';

import routes from '../../../routes/urls';

Expand Down Expand Up @@ -62,6 +63,11 @@ class Tweets extends React.Component {
axios.get(`${routes.api.tweets}${page}`)
.then(res => {
const { data, page, total_pages } = res.data;
// format date data
for (let i=0; i<data.length; i++) {
data[i].date = moment(data[i].date).format('DD-MM-YYYY HH:mm');
}

this.setState({
data,
page,
Expand Down

0 comments on commit c21db87

Please sign in to comment.