ijunseong

Update: fetch channel info from server

...@@ -117,7 +117,29 @@ export class ChannelList extends React.Component { ...@@ -117,7 +117,29 @@ export class ChannelList extends React.Component {
117 117
118 componentDidMount() { 118 componentDidMount() {
119 console.log('channel cdm'); 119 console.log('channel cdm');
120 - fetch('http://localhost:3303/list').then( res => res.json()) 120 + fetch('http://localhost:3303/channels').then( res => res.json())
121 + .then(data => {
122 + var tmpChannels = [];
123 + data.map((channel, index) => {
124 + var tmp = {
125 + id: channel.display_name || " ",
126 + nickname: channel.name || " ",
127 + category: channel.game || "Not playing",
128 + view: channel.views || 0,
129 + url: channel.url || "https://www.twitch.tv/",
130 + isPlay: false,
131 + }
132 + tmpChannels.push(tmp);
133 + })
134 + return tmpChannels;
135 + }).then( channels => {
136 + this.setState({
137 + channels: channels,
138 + xisPlaying: null,
139 + })
140 + })
141 + }
142 + /* fetch('http://localhost:3303/list').then( res => res.json())
121 .then(data => { 143 .then(data => {
122 var tmpChannels = [] 144 var tmpChannels = []
123 data.channels.map((channel, index) => { 145 data.channels.map((channel, index) => {
...@@ -138,8 +160,10 @@ export class ChannelList extends React.Component { ...@@ -138,8 +160,10 @@ export class ChannelList extends React.Component {
138 channels: channels, 160 channels: channels,
139 xisPlaying: null, 161 xisPlaying: null,
140 }) 162 })
141 - }) 163 + }) */
142 - } 164 +
165 +
166 +
143 167
144 render() { 168 render() {
145 return ( 169 return (
......