-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.html
More file actions
45 lines (35 loc) · 977 Bytes
/
index.html
File metadata and controls
45 lines (35 loc) · 977 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Electron App</title>
</head>
<body>
<h1>Posts:</h1>
<ul id="postList"></ul>
<small>Refresh and you'll see a new post added.</small>
<script>
var typeorm = require("typeorm");
typeorm.createConnection().then(() => {
var post = {
title: "post title",
text: "post text"
};
return typeorm.getRepository("Post").save(post);
}).then(() => {
console.log("Saved successfully!");
return typeorm.getRepository("Post").find();
}).then(posts => {
console.log("Posts: ", posts);
let ul = document.getElementById("postList");
posts.forEach(post => {
var li = document.createElement('li');
li.innerText = post.id + ". " + post.title;
ul.appendChild(li);
});
}).catch(error => {
console.error("Error: ", error);
});
</script>
</body>
</html>