-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08b370f
commit fd83feb
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import * as client from "./client.js"; | ||
|
||
async function pollExampleAsync() { | ||
let postsDiv = document.getElementById("posts"); | ||
let x = document.createElement("div"); | ||
// x.classList.add("post-item"); | ||
const itemId = 126809; | ||
let data = null; | ||
while (data === null) { | ||
data = await client.getItemAsync(itemId); | ||
} | ||
let t = document.createElement("h3"); | ||
let tt = document.createTextNode(data.title); | ||
t.appendChild(tt); | ||
x.appendChild(t); | ||
// console.log(data); | ||
for (const id of data.parts) { | ||
let data = await client.getItemAsync(id); | ||
let h = document.createElement("h5"); | ||
let hT = document.createTextNode(data.text); | ||
let s = document.createElement("p"); | ||
let sT = document.createTextNode(data.score); | ||
h.appendChild(hT); | ||
s.appendChild(sT); | ||
x.appendChild(h); | ||
x.appendChild(s); | ||
} | ||
postsDiv.appendChild(x); | ||
return data; | ||
} | ||
|
||
window.addEventListener("load", async () => { | ||
await pollExampleAsync(); | ||
}) |