-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPerson.js
64 lines (57 loc) · 1.3 KB
/
Person.js
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import React from "react";
import Axios from "axios";
export default class Person extends React.Component {
state = {
persons: []
};
// componentDidMount() {
// Axios.get("https://jsonplaceholder.typicode.com/users").then(res => {
// console.log(res);
// this.setState({
// persons: res.data
// });
// });
// }
componentDidMount() {
Axios.get(`https://jsonplaceholder.typicode.com/users`)
.then(res => {
const persons = res.data;
console.log(res.data);
this.setState({ persons });
})
.catch(error => {
console.log("Wrong api call");
});
}
deleteUserHandler(person) {
debugger;
}
render() {
return (
<ul>
{this.state.persons.map(person => (
<div>
{/* <p key={person.id}>{person.name}</p> */}
<li>
{person.address.city}
</li>
{/* <button onClick={this.deleteUserHandler.bind(this, person.id)}>delete</button> */}
</div>
))}
</ul>
);
}
}
//import React from "react";
//
//function Person({ person }) {
// return (
// <div>
// <h2>
// I am {person.name}. I am {person.age} years old. I know {person.skill}.
// </h2>
// </div>
// );
//}
//
//export default Person;