-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathad.js
More file actions
40 lines (32 loc) · 1.17 KB
/
Copy pathad.js
File metadata and controls
40 lines (32 loc) · 1.17 KB
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
document.getElementById("form").addEventListener('submit',postReq);
function postReq(e) {
e.preventDefault()
let brand = document.getElementById("cars").value;
let type = document.getElementById("type").value;
let year = document.getElementById("year").value;
let driven = document.getElementById("driven").value;
let description = document.getElementById("description").value;
let price = document.getElementById("price").value;
fetch('https://fakestoreproducts.herokuapp.com/cars',{
method:"POST",
body:JSON.stringify(
{
brand: brand,
year: year,
type: type,
kms: driven,
description: description,
price : price
}
),
headers: {
"Content-type": "application/json"
}
})
.then(res=>res.json())
.then(json=> {
alert("Please Verify OTP For Create Add")
window.location.href="otp.html"
})
.catch(()=> alert("Adding Failed!!"))
}