-
Notifications
You must be signed in to change notification settings - Fork 0
/
crudcrud.js
41 lines (31 loc) · 994 Bytes
/
crudcrud.js
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
function getDetails(event) {
event.preventDefault();
let Name = document.querySelector('#name').value;
let Email = document.querySelector('#mail').value;
let Phone = document.querySelector('#phone').value;
let ul = document.querySelector('#users');
function displayData(obj) {
let li = document.createElement('li');
li.appendChild(document
.createTextNode(`${obj.Name} - ${obj.Email} - ${obj.Phone}`));
ul.appendChild(li);
li.style.listStyleType = 'disc';
}
let obj = {
Name,
Email,
Phone
}
axios
.post('https://crudcrud.com/api/e278d2279049467c9386814127fc000/appointmentData', obj)
.then(response => {
displayData(response.data);
})
.catch(err => {
document.body.innerHTML += '<h4>Something went wrong.</h4>';
console.log(err);
})
document.querySelector('#name').value = '';
document.querySelector('#mail').value = '';
document.querySelector('#phone').value = '';
}