This commit is contained in:
Niel 2019-02-07 23:59:36 +01:00
parent 6079f265fd
commit 1e38cd840b
5 changed files with 52 additions and 20 deletions

View file

@ -0,0 +1 @@
.channelList li span {}

View file

@ -0,0 +1,41 @@
import React, { Component } from 'react';
import ChannelService from '../../services/chanel';
import './ChannelList.scss';
export default class Channellist extends Component<any, any> {
service: ChannelService;
constructor(props: any) {
super(props);
this.state = {
loaded: false,
channels: [],
};
this.service = new ChannelService();
}
componentDidMount() {
fetch('http://haveachin.de:1888/v1/channels')
.then(res => res.json())
.then(data => this.setState({ channels: data, loaded: true }))
.catch(e => console.log(e));
}
public render() {
const { loaded, channels } = this.state;
console.log(this.state);
if (!loaded) {
return <div className='loading'>Loading...</div>;
} else {
return (
<ul className='channelList'>
{channels.map((e: Channel) => (
<li>
<span>#{e.id} </span>
{e.name}
</li>
))}
</ul>
);
}
}
}

View file

@ -0,0 +1,10 @@
.channel-view {
background-color: green;
width: 20%;
height: auto;
margin: auto;
}
.channel-view ul {
text-align: left
}

View file

@ -1,20 +0,0 @@
import React, { Component } from 'react';
export default class Channellist extends Component<any, any> {
constructor(props: any) {
super(props);
this.state = {
data: 'Loading...',
};
}
componentDidMount() {
fetch('https://ts.cliffbreak.de/v1/channels')
.then(response => response.json())
.then(data => this.setState({ data }));
}
public render() {
const { data } = this.state;
return <div>{data}</div>;
}
}