forked from Ru-Hacks/Coronacast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
news.js
39 lines (30 loc) · 955 Bytes
/
news.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
/*
var url = 'http://newsapi.org/v2/top-headlines?' +
'country=us&' +
'apiKey=f53bb7e9ed3545deb75d7215f07dca25';
var req = new Request(url);
fetch(req)
.then(function(response) {
console.log(response.json());
})
*/
// var el = document.getElementById('news1');
// if(el){
// el.addEventListener('click', getNews);
// }
//document.getElementById("news1").addEventListener("click", getNews);
function getNews(){
// var url ='http://newsapi.org/v2/everything?' +
// 'q=Corona&' +
// 'from=2020-05-00&' +
// 'sortBy=popularity&' +
// 'apiKey=f53bb7e9ed3545deb75d7215f07dca25';
var url = 'https://newsapi.org/v2/top-headlines?q=Corona&country=ca&apiKey=f53bb7e9ed3545deb75d7215f07dca25';
var req = new Request(url);
fetch(req)
.then(function(response) {
let data = response.json();
console.log("poopy");
console.log(data);
});
}