-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
62 lines (54 loc) · 2.04 KB
/
index.html
File metadata and controls
62 lines (54 loc) · 2.04 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form method="post" id="form-receita">
<!-- ATUALIZAR O VALUE NO REACT PARA PEGAR A DATA DE HOJE-->
<input type="date" value="2025-06-08" min="2025-01-01" max="2025-06-08" name="dataReceita" id="dataReceita" placeholder="data">
<input type="text" name="descricaoReceita" id="descricaoReceita" placeholder="descricao">
<input type="text" name="valorReceita" id="valorReceita" placeholder="valor">
<button type="submit">Adicionar</button>
</form>
<script>
//pegando data de hoje para o input date
const date = new Date();
const dataHoje = `0${date.getDate()}-0${date.getMonth()}-${date.getFullYear()}`
console.log(dataHoje)
//selecionando os inputs
const formRec = document.querySelector('#form-receita');
const dataRec = document.querySelector('#dataReceita');
const descRec = document.querySelector('#descricaoReceita');
const valRec = document.querySelector('#valorReceita');
formRec.addEventListener('submit', (e) => {
e.preventDefault();
enviaDados();
})
//funcao para enviar os dados para o backend
function enviaDados(){
const params = {
data: dataRec.value,
descricao: descRec.value,
valor: valRec.value
};
const options = {
method: 'POST',
headers: {
'Content-Type':'application/json',
'Accept':'application/json'
},
body: JSON.stringify( params )
};
console.log(options.body)
fetch('http://localhost:3000/prestacao', options)
.then(res => res.json())
.then(res => {
return res
})
}
</script>
</body>
</html>