diff --git a/client/src/components/MediaList.js b/client/src/components/MediaList.js index 4a47e8d..1045a14 100644 --- a/client/src/components/MediaList.js +++ b/client/src/components/MediaList.js @@ -6,32 +6,40 @@ import styles from './css'; import axios from 'axios'; class MediaList extends Component { + state = {tvShowList: []}; + componentDidMount() { this.getMostWatched(); } getMostWatched = async params => { const res = await axios.get('/api/recommend/most-watched'); - console.log(res); - return res; + this.setState({tvShowList: res.data}); }; render() { - const {classes} = this.props; - return ( - - ); + const mediaList = this.state.tvShowList.map(show => { + return ( + + ); + }); + return
{mediaList}
; } } diff --git a/server/services/recommend/index.js b/server/services/recommend/index.js index b5c68ae..a6e3f4b 100644 --- a/server/services/recommend/index.js +++ b/server/services/recommend/index.js @@ -6,7 +6,7 @@ const getMostWatched = async (req, res) => { try { console.log('mike'); const mostWatched = await models.PlexLibrary.findAll({ - where: {UserId: req.user.id, views: {[Op.gt]: 0}}, + where: {UserId: req.user.id, type: 'show', views: {[Op.gt]: 0}}, }); console.log('mostwatched', mostWatched); res.json(mostWatched);