build
This commit is contained in:
parent
ef9b4c746c
commit
4e1b415614
4 changed files with 74 additions and 16 deletions
|
|
@ -59,7 +59,14 @@ class ClassPilao {
|
|||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
return await response.json();
|
||||
const texto = await response.text();
|
||||
try {
|
||||
const json = JSON.parse(texto);
|
||||
return json;
|
||||
}
|
||||
catch {
|
||||
return p_respostas_1.respostaComuns.erro("Consulta não retornou json válido", [texto]);
|
||||
}
|
||||
}
|
||||
catch (erro) {
|
||||
console.error(erro);
|
||||
|
|
@ -112,13 +119,14 @@ class ClassPilao {
|
|||
headers: { "Content-Type": "application/json" },
|
||||
})
|
||||
.then(async (r) => {
|
||||
const texto = await r.text();
|
||||
try {
|
||||
return await r.json();
|
||||
const json = JSON.parse(texto);
|
||||
return json;
|
||||
}
|
||||
catch {
|
||||
return p_respostas_1.respostaComuns.erro("Consulta não retornou json válido", [
|
||||
await r.text(),
|
||||
r.statusText,
|
||||
texto,
|
||||
]);
|
||||
}
|
||||
})
|
||||
|
|
@ -145,7 +153,18 @@ class ClassPilao {
|
|||
body: JSON.stringify(parametros),
|
||||
headers: { "Content-Type": "application/json" },
|
||||
})
|
||||
.then((r) => r.json())
|
||||
.then(async (r) => {
|
||||
const texto = await r.text();
|
||||
try {
|
||||
const json = JSON.parse(texto);
|
||||
return json;
|
||||
}
|
||||
catch {
|
||||
return p_respostas_1.respostaComuns.erro("Consulta não retornou json válido", [
|
||||
texto,
|
||||
]);
|
||||
}
|
||||
})
|
||||
.catch((e) => p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message]));
|
||||
if (__classPrivateFieldGet(this, _ClassPilao_ver_log, "f"))
|
||||
console.log(`[PILÃO]: buscar dados de "${JSON.stringify(parametros)}" para "${url}".`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue