forked from AustinCodingAcademy/javascript-workbook
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
50 lines (42 loc) · 1.09 KB
/
App.js
File metadata and controls
50 lines (42 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import React, { Component } from 'react';
import './App.css';
import CharacterCard from './CharacterCard.js';
class App extends Component {
constructor(props){
super(props);
this.state = {
characters: [],
}
}
componentDidMount(){
fetch('https://swapi.co/api/people/')
.then((response) => response.json())
.then((responseJson) => {
return this.setState({characters: responseJson.results})
})
.catch((error) => {
console.error(error);
});
}
renderCharacters() {
console.log('in renderCharacters');
console.log('characters array', this.state.characters);
}
render() {
return (
<div>
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h2>Star Wars</h2>
</div>
</div>
<div className="App">
<img src={logo} className="App-logo" alt="logo" />
{this.renderCharacters()}
</div>
</div>
);
}
}
export default App;