@@ -3,28 +3,76 @@ import './BitCoin.css';
33
44class BitCoin extends Component {
55
6+
67 constructor ( ) {
78 super ( ) ;
89 this . state = {
9- 'bitcoin' : null
10+ result : [ ]
1011 } ;
1112 }
1213
1314 componentDidMount = ( ) => {
14- // fetch('https://api.coindesk.com/v1/bpi/currentprice.json').then(customers=>{
15- // console.log('Vivek');
16- // console.log(customers.json());
17- // // this.setState({'bitcoin':customers});
18- // });
15+ fetch ( 'https://api.coindesk.com/v1/bpi/currentprice.json' ) . then ( customers => {
16+ return customers . json ( ) ;
17+ } ) . then ( data => {
18+ this . setState ( {
19+ 'updated_isodate' :data . time . updatedISO ,
20+ 'disclaimer' :data . disclaimer ,
21+ 'chartName' :data . chartName ,
22+ 'usd_symbol' :data . bpi . USD . code ,
23+ 'usd_desc' :data . bpi . USD . description ,
24+ 'usd_rate' :data . bpi . USD . rate_float ,
25+ 'eur_symbol' :data . bpi . EUR . code ,
26+ 'eur_desc' :data . bpi . EUR . description ,
27+ 'eur_rate' :data . bpi . EUR . rate_float ,
28+ 'gbp_symbol' :data . bpi . GBP . code ,
29+ 'gbp_desc' :data . bpi . GBP . description ,
30+ 'gbp_rate' :data . bpi . GBP . rate_float ,
31+ } ) ;
32+ console . log ( "Vivek Java : " + JSON . stringify ( data ) ) ;
33+ } , error => {
34+ console . log ( "Vivek Error : " + JSON . stringify ( error ) ) ;
35+ } ) ;
1936 }
2037
2138 render ( ) {
2239 return (
2340 < div className = "bitcoin" >
24- VIvek
41+ < label className = 'head' > { this . state . chartName } </ label > < br /> < hr /> < br />
42+ < label className = 'note' > < strong > Disclaimer :</ strong > { this . state . disclaimer } </ label > < br /> < br />
43+ < center >
44+ < table border = '1' className = 'table' >
45+ < thead >
46+ < tr >
47+ < th className = 'table-head' > Symbol</ th >
48+ < th className = 'table-head' > Description</ th >
49+ < th className = 'table-head' > Rate</ th >
50+ </ tr >
51+ </ thead >
52+ < tbody >
53+ < tr >
54+ < td > { this . state . usd_symbol } </ td >
55+ < td > { this . state . usd_desc } </ td >
56+ < td > { this . state . usd_rate } </ td >
57+ </ tr >
58+ < tr >
59+ < td > { this . state . eur_symbol } </ td >
60+ < td > { this . state . eur_desc } </ td >
61+ < td > { this . state . eur_rate } </ td >
62+ </ tr >
63+ < tr >
64+ < td > { this . state . gbp_symbol } </ td >
65+ < td > { this . state . gbp_desc } </ td >
66+ < td > { this . state . gbp_rate } </ td >
67+ </ tr >
68+ </ tbody >
69+ </ table >
70+ </ center >
71+
2572 </ div >
2673 ) ;
2774 }
2875}
2976
77+
3078export default BitCoin ;
0 commit comments