-
Notifications
You must be signed in to change notification settings - Fork 0
/
Background.tsx
46 lines (39 loc) · 1.12 KB
/
Background.tsx
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
import React, { Component } from 'react'
const API = 'https://api.github.com/users/avinaash-sharma/repos';
export default class Background extends React.Component<{},any> {
constructor(props){
super(props);
this.state={
data:[],
}
}
componentDidMount() {
return fetch(API)
.then((response) => response.json())
.then((responseJson) => {
this.setState({
data: responseJson
}, function() {
// In this block you can do something with new state.
console.log(this.state.data);
});
})
.catch((error) => {
console.error(error);
});
}
render() {
const values=this.state.data;
return (
<div>
{
values.map((element,index) => {
return(
<h4 key={index}>{element.name}</h4>
)
})
}
</div>
)
}
}