I'm pulling an API and putting its data inside a table, but that data goes to the table part that is the td, but I want to put the date the data was implemented there, so the date would stay in th.
Currently my code looks like this:
<div class="container">
<div class="table-responsive">
<table class="table" width="100px" align="center">
<thead>
<tr class="cliente">
<th class="cor">Quantidade</th>
</tr>
<tr class="clientess">
<th class="cor">Nº.Pedido</th>
</tr>
<tr class="fiscal">
<th class="cor">Nota Fiscal</th>
</tr>
<tr class="entprevista">
<th class="cor">Entrega Prevista</th>
</tr>
<tr class="data">
<th class="cor">Data</th>
</tr>
</thead>
</table>
</div>
</div>
PUSHING API
function load() {
var xhr = new XMLHttpRequest();
xhr.open("GET", "API AQUI");
xhr.addEventListener("load", function() {
var resposta = xhr.responseText;
console.log("ola1");
var clientes = JSON.parse(resposta);
console.log("ola2");
console.log(clientes);
for (var i =0; i < 1; i++){
console.log("ola3");
var clientes_1 = clientes.TRACKER[i];
adicionaClienteNaTabelaViagem(clientes_1);
adicionaClienteNaTabelaViagemLogo(clientes_1);
AdicionaNotaFiscal(clientes_1);
AdicionaEntPrevista(clientes_1);
AdicionaStatus(clientes_1);
}
});
xhr.send();
}
window.onload = load;
SOME DATA THAT I PLACE IN TABLE TAB
function AdicionaNotaFiscal(fiscal) {
var notaTr = fiscalTr(fiscal);
var tabelas = document.querySelector(".fiscal");
tabelas.appendChild(notaTr);
}
function fiscalTr(fiscal) {
var notaTr = document.createElement("tr");
notaTr.classList.add("fiscal");
notaTr.appendChild(notaTd(fiscal.NFISCA, "info-nota-fiscal"));
return notaTr;
}
function notaTd(dado, classe) {
var teste = document.querySelector(".fiscal");
var td = document.createElement("td");
td.classList.add(classe);
td.textContent = dado;
return td;
}
Then in this th that is written "quantity", "invoice" ... I wanted it to be the date of the day I posted the api