This commit is contained in:
Luiz Silva 2024-10-02 14:34:15 -03:00
parent d0808a86dc
commit ef9b4c746c
4 changed files with 33 additions and 4 deletions

View file

@ -105,7 +105,17 @@ class ClassPilao {
body: JSON.stringify({ tabela, registros: bloco }),
headers: { "Content-Type": "application/json" },
})
.then((r) => r.json())
.then(async (r) => {
try {
return await r.json();
}
catch {
return respostaComuns.erro("Consulta não retornou json válido", [
await r.text(),
r.statusText,
]);
}
})
.catch((e) => respostaComuns.erro(`Erro ao ${acao} registros`, [e.message]));
if (resp.eErro)
return resp;

View file

@ -111,7 +111,17 @@ class ClassPilao {
body: JSON.stringify({ tabela, registros: bloco }),
headers: { "Content-Type": "application/json" },
})
.then((r) => r.json())
.then(async (r) => {
try {
return await r.json();
}
catch {
return p_respostas_1.respostaComuns.erro("Consulta não retornou json válido", [
await r.text(),
r.statusText,
]);
}
})
.catch((e) => p_respostas_1.respostaComuns.erro(`Erro ao ${acao} registros`, [e.message]));
if (resp.eErro)
return resp;

View file

@ -1,6 +1,6 @@
{
"name": "p-drives",
"version": "0.169.0",
"version": "0.170.0",
"description": "",
"main": "src/index.ts",
"exports": {

View file

@ -148,7 +148,16 @@ class ClassPilao {
body: JSON.stringify({ tabela, registros: bloco }),
headers: { "Content-Type": "application/json" },
})
.then((r) => r.json())
.then(async (r) => {
try {
return await r.json()
} catch {
return respostaComuns.erro("Consulta não retornou json válido", [
await r.text(),
r.statusText,
])
}
})
.catch((e) =>
respostaComuns.erro(`Erro ao ${acao} registros`, [e.message]),
)