ijunseong

Update: fetch channel info from server

......@@ -117,7 +117,29 @@ export class ChannelList extends React.Component {
componentDidMount() {
console.log('channel cdm');
fetch('http://localhost:3303/list').then( res => res.json())
fetch('http://localhost:3303/channels').then( res => res.json())
.then(data => {
var tmpChannels = [];
data.map((channel, index) => {
var tmp = {
id: channel.display_name || " ",
nickname: channel.name || " ",
category: channel.game || "Not playing",
view: channel.views || 0,
url: channel.url || "https://www.twitch.tv/",
isPlay: false,
}
tmpChannels.push(tmp);
})
return tmpChannels;
}).then( channels => {
this.setState({
channels: channels,
xisPlaying: null,
})
})
}
/* fetch('http://localhost:3303/list').then( res => res.json())
.then(data => {
var tmpChannels = []
data.channels.map((channel, index) => {
......@@ -138,8 +160,10 @@ export class ChannelList extends React.Component {
channels: channels,
xisPlaying: null,
})
})
}
}) */
render() {
return (
......