removido registros undefined

This commit is contained in:
Luiz H. R. Silva 2024-06-21 13:47:59 -03:00
parent 4860b2c036
commit ceab73c21c
4 changed files with 29 additions and 4 deletions

View file

@ -30,7 +30,9 @@ export const enviar_registros = ({ conta, produto, emDesenvolvimento }) => ({ re
const url = new URL(`${baseUrlPilao(emDesenvolvimento)}${PREFIXO}/${Object.keys({ enviar_registros })[0]}/${produto}/${conta}`);
const tamanhoBlocos = 1000;
while (registros.length > 0) {
const bloco = registros.splice(0, tamanhoBlocos);
const bloco = registros
.splice(0, tamanhoBlocos)
.map((r) => Object.fromEntries(Object.entries(r).map(([k, v]) => [k, v === undefined ? null : v])));
const resp = yield node_fetch(url.toString(), {
method: "POST",
body: JSON.stringify({ tabela, registros: bloco }),