-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolygonapi.js
47 lines (31 loc) · 1.55 KB
/
polygonapi.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
const api_url = 'https://api.polygon.io/v2/reference/news?apiKey=p7c8V21Cyw6jFzkxVm6DjVuaromXeTpo'
async function getInfo() {
const response = await fetch(api_url);
// Parsing it to JSON format
const data = await response.json();
console.log(data.results);
const thisStockData = data;
var marketnews = document.getElementById("marketnewslist");
data.results.forEach(element => {
let title = element.title;
let ticker = element.tickers;
let description = element.description;
let publishername = element.publisher.name;
let articlelink = element.article_url;
let li = document.createElement("li");
li.innerHTML += '<span id="articleTickers">' + 'Tickers: ' + ticker + '</span><br>';
li.innerHTML += '<span id="articleTitle">' + title + '</span><br>';
li.innerHTML += '<span id="articleDescription">' + description + '</span><br>';
li.innerHTML += '<span id="articlePublisher">' + 'Source: ' + publishername + '</span><br>';
let thislink = document.createElement("a");
thislink.href = articlelink;
thislink.target = '_blank';
thislink.innerHTML = "Read More";
marketnews.append(li);
li.append(thislink);
});
/*const thisLink = document.getElementById("linktoarticle");
thisLink.innerHTML = "Read more";
thisLink.setAttribute("href", articlelink);*/
}
getInfo();