Subject | Hash | Author | Date (UTC) |
---|---|---|---|
Add AJAX request to list component | 3dd5f784d209cc1cfeb22bbc93aaf2c871e2c69b | antcalatayud | 2018-04-24 12:29:22 |
Start creating list componet | c8bc3d6bb9b4980e1305d401be2fe67c8933a7f8 | antcalatayud | 2018-04-24 10:31:23 |
Add logo | eed8364675e78cfa795550bff03682d49a8ed115 | antcalatayud | 2018-04-24 10:23:07 |
Add styling | 866cbbbc94ce81e8b8b6b88da9f86d2d4153e509 | antcalatayud | 2018-04-24 10:18:43 |
Create fist component and render App | b713ed055b8691a0fd89792d136e0ef9ed86f07c | antcalatayud | 2018-04-24 10:11:22 |
Add init files | d81df9e3d230bcb49f0bb31c43cffad97532d321 | antcalatayud | 2018-04-24 09:51:04 |
Initial commit | 3c3626d89f221374c92ee04aed1eaa8616f3977e | Antonio Calatayud | 2018-04-24 09:03:03 |
File | Lines added | Lines deleted |
---|---|---|
src/components/list/List.js | 23 | 0 |
File src/components/list/List.js changed (mode: 100644) (index 3ea5979..eb63e0f) | |||
... | ... | class List extends React.Component { | |
11 | 11 | }; | }; |
12 | 12 | } | } |
13 | 13 | ||
14 | componentDidMount(){ | ||
15 | this.setState({ loading: true }); | ||
16 | |||
17 | fetch('https://api.udilia.com/coins/v1/cryptocurrencies?page=1&perPage=20') | ||
18 | .then(response => { | ||
19 | return response.json().then(json => { | ||
20 | return response.ok ? json : Promise.reject(json); | ||
21 | }); | ||
22 | }) | ||
23 | .then((data) => { | ||
24 | this.setState({ | ||
25 | loading: false, | ||
26 | currencies: data.currencies | ||
27 | }); | ||
28 | }) | ||
29 | .catch((error) => { | ||
30 | this.setState({ | ||
31 | loading: false, | ||
32 | error: error.errorMessage | ||
33 | }); | ||
34 | }); | ||
35 | } | ||
36 | |||
14 | 37 | render() { | render() { |
15 | 38 | if (this.state.loading) { | if (this.state.loading) { |
16 | 39 | return <div>Loading...</div> | return <div>Loading...</div> |