-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_user.js
38 lines (28 loc) · 817 Bytes
/
add_user.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
async function add_user() {
const name = document.getElementById("name");
const uName = name.value;
const age = document.getElementById("age");
const uAge = age.value;
const cpf = document.getElementById("cpf");
const uCpf = cpf.value;
const email = document.getElementById("email");
const uEmail = email.value;
console.log(uName, uAge, uCpf, uEmail)
console.log(url)
let html
const dom = document.getElementById('resposta')
await axios.post(`${url}/users`, {
name: uName,
age: uAge,
cpf: uCpf,
email: uEmail
})
.then(function (response) {
html = response
dom.innerHTML = html.data;
})
.catch(function (error) {
console.log(error);
dom.innerHTML = "<h1>Ocorreu algum erro de comunicação com o servidor</h1>"
})
}