I made two date inputs, and when I click "generate" it shows in the console the product that has these dates, but it is a variable, how do I turn a class and play in html? there everytime I call the class it appears, eg:
<h2 class="produto-1"></h2>
Then he would show up there.
Code:
<body>
<input type="date" id="inicio">
<input type="date" id="fim">
<button onclick="PostData();">GERAR</button>
<!-- -->
<script>
function PostData() {
var inicio,fim;
inicio = document.getElementById('inicio').value;
fim = document.getElementById('fim').value;
fetch('http://localhost/api', {
method: 'POST',
headers: {'Content-Type':'application/x-www-form-urlencoded'},
body: 'inicio=${inicio}&fim=${fim}'
}).then(response => response.json().then(data => ({
data: data,
status: response.status
})
).then(res => {
var insere = (res.data.dados.nome);
console.log(insere);
})
)
}
</script>
</body>