-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
36 lines (36 loc) · 1.16 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel
</head>
<input id="name" placeholder="write your name">
<br>
<input id="message"></input>
<button id="b1">send</button>
<div id="container"></div>
<script>
const button = document.getElementById('b1');
const message = document.getElementById('message');
const container = document.getElementById('container');
const name = document.getElementById('name');
button.onclick = () => {
let value = message.value;
console.log(value);
fetch("http://localhost:3001/send/" + (name.value !== "" ? (name.value + ":") : "") + message.value);
}
setInterval(()=>{
fetch("http://localhost:3001/get").then((res)=>{
return res.json();
}).then((jsonData)=>{
console.log(jsonData);
let chat = jsonData.chat;
container.innerHTML = chat;
})
}, 1000);
console.log();
</script>
</body>
</html>