removido registros undefined
This commit is contained in:
parent
afa28a0699
commit
4860b2c036
1 changed files with 9 additions and 2 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
import node_fetch from "cross-fetch"
|
import node_fetch from "cross-fetch"
|
||||||
import type { tipoResposta } from "p-respostas"
|
import type { tipoResposta } from "p-respostas"
|
||||||
import { respostaComuns } from "p-respostas"
|
import { respostaComuns } from "p-respostas"
|
||||||
import { z } from "zod"
|
import { map, z } from "zod"
|
||||||
import {
|
import {
|
||||||
PREFIXO,
|
PREFIXO,
|
||||||
baseUrlPilao,
|
baseUrlPilao,
|
||||||
|
|
@ -48,7 +48,14 @@ export const enviar_registros =
|
||||||
const tamanhoBlocos = 1000
|
const tamanhoBlocos = 1000
|
||||||
|
|
||||||
while (registros.length > 0) {
|
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 = await node_fetch(url.toString(), {
|
const resp = await node_fetch(url.toString(), {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({ tabela, registros: bloco }),
|
body: JSON.stringify({ tabela, registros: bloco }),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue