forked from yay14/newsApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
58 lines (55 loc) · 1.12 KB
/
App.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
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import { render } from '@testing-library/react';
class App extends Component
{
constructor(props)
{
super(props);
this.state={
articles:[]
}
}
componentDidMount()
{
fetch('http://newsapi.org/v2/everything?q=bitcoin&from=2020-03-27&sortBy=publishedAt&apiKey=0862452198de4c9eb58d671919b37b24')
.then((response) => {
return response.json();
})
.then((myJason) => {
//console.log(data);
this.setState({
articles: myJason.articles
});
});
}
render(){
console.log(this.state)
return (
<div className="App">
{
this.state.articles.map((item,index)=>{
return(
<div>
<h2 style={{textAlign:'left' }}>
{item.title}
</h2>
<a href={item.url}>
Read More
</a>
<b>
{item.author}
</b>
<img src={item.urlToImage} style={{width:'50vv'}}/>
<p>
{item.content}
</p>
</div>
);
})}
</div>
);
}
}
export default App;