trying to fetch data
This commit is contained in:
parent
142ca7e6de
commit
70c7aa60dc
5 changed files with 51 additions and 46 deletions
33
src/App.css
33
src/App.css
|
@ -1,32 +1,7 @@
|
|||
body {
|
||||
background-color: pink;
|
||||
}
|
||||
|
||||
.App {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.App-logo {
|
||||
animation: App-logo-spin infinite 20s linear;
|
||||
height: 40vmin;
|
||||
}
|
||||
|
||||
.App-header {
|
||||
background-color: #282c34;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: calc(10px + 2vmin);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.App-link {
|
||||
color: #61dafb;
|
||||
}
|
||||
|
||||
@keyframes App-logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
|
25
src/App.tsx
25
src/App.tsx
|
@ -1,25 +1,16 @@
|
|||
import React, { Component } from 'react';
|
||||
import logo from './logo.svg';
|
||||
|
||||
import Channels from './components/channels/Channels';
|
||||
import Header from './components/Header/Header';
|
||||
|
||||
import './App.css';
|
||||
|
||||
class App extends Component {
|
||||
render() {
|
||||
public render() {
|
||||
return (
|
||||
<div className="App">
|
||||
<header className="App-header">
|
||||
<img src={logo} className="App-logo" alt="logo" />
|
||||
<p>
|
||||
Edit <code>src/App.tsx</code> and save to reload.
|
||||
</p>
|
||||
<a
|
||||
className="App-link"
|
||||
href="https://reactjs.org"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Learn React
|
||||
</a>
|
||||
</header>
|
||||
<div className='App'>
|
||||
<Header />
|
||||
<Channels />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
10
src/components/Header/Header.css
Normal file
10
src/components/Header/Header.css
Normal file
|
@ -0,0 +1,10 @@
|
|||
.App-header {
|
||||
background-color: #282c34;
|
||||
min-height: 100px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: calc(10px + 2vmin);
|
||||
color: white;
|
||||
}
|
9
src/components/Header/Header.tsx
Normal file
9
src/components/Header/Header.tsx
Normal file
|
@ -0,0 +1,9 @@
|
|||
import React, { Component } from 'react';
|
||||
import './Header.css';
|
||||
class Header extends Component {
|
||||
public render() {
|
||||
return <div className='App-header'>Cliffbreak.de</div>;
|
||||
}
|
||||
}
|
||||
|
||||
export default Header;
|
20
src/components/channels/Channels.tsx
Normal file
20
src/components/channels/Channels.tsx
Normal file
|
@ -0,0 +1,20 @@
|
|||
import React, { Component } from 'react';
|
||||
|
||||
export default class Channels 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>;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue