-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
47 lines (44 loc) · 1.21 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
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html>
<html >
<head>
<title> Products</title>
<link rel="stylesheet" href="/public/style.css">
</head>
<body>
<div id="root">New Product</div>
<label>Name</label>
<input id="name" type="text">
<br>
<label>Price</label>
<input id="price" type="number">
<br>
<label>Quantity</label>
<input id="quantity" type="number">
<br>
<button id="add">ADD</button>
</body>
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
<script>
let user = {name: '', price: '', quantity: ''}
$('#add').click(function(){
user.name = $('#name').val()
user.email = $('#price').val()
user.password = $('#quantity').val()
$.ajax({
method: "POST",
url: '/index.html',
data: user
}).done(function(response){
console.log(response)
localStorage.setItem('token',response.token)
localStorage.setItem('userID',response.user._id)
}).fail(function(response){
alert("Something went wrong")
console.log(response)
})
})
</script>
</html>