diff --git a/src/App.scss b/src/App.scss index ab3fb24..74ebcac 100644 --- a/src/App.scss +++ b/src/App.scss @@ -1,4 +1,5 @@ body { background-color: #4a4a4a; - font-size: 160% + font-size: 160%; + color: #fff } diff --git a/src/components/Channel/ChannelList.tsx b/src/components/Channel/ChannelList.tsx index ffb697a..3e97e96 100644 --- a/src/components/Channel/ChannelList.tsx +++ b/src/components/Channel/ChannelList.tsx @@ -1,27 +1,24 @@ import React, { Component } from 'react'; -import ChannelService from '../../services/chanel'; +import ChannelService from '../../services/ChannelService'; import './ChannelList.scss'; export default class Channellist extends Component { - service: ChannelService; constructor(props: any) { super(props); this.state = { loaded: false, channels: [], }; - this.service = new ChannelService(); } componentDidMount() { - ChannelService.getAllChannels() - .then(data => this.setState({ channels: data, loaded: true })) - .catch(e => console.log(e)); + ChannelService.fetchAllChannels().then(data => { + this.setState({ channels: data, loaded: true }); + }); } public render() { const { loaded, channels } = this.state; - console.log(this.state); if (!loaded) { return
Loading...
; } else { diff --git a/src/services/ChannelService.ts b/src/services/ChannelService.ts new file mode 100644 index 0000000..15db882 --- /dev/null +++ b/src/services/ChannelService.ts @@ -0,0 +1,9 @@ +const API_URL = 'http://haveachin.de:1888/v1/channels'; + +export default class ChannelService { + public static async fetchAllChannels() { + const response = await fetch('http://haveachin.de:1888/v1/channels'); + const json = await response.json(); + return json; + } +} diff --git a/src/services/chanel.ts b/src/services/chanel.ts deleted file mode 100644 index a2bd16b..0000000 --- a/src/services/chanel.ts +++ /dev/null @@ -1,9 +0,0 @@ -const API_URL = 'http://haveachin.de:1888/v1/channels'; - -export default class ChannelService { - public static getAllChannels() { - return fetch('http://haveachin.de:1888/v1/channels').then(res => - res.json() - ); - } -}