build
This commit is contained in:
parent
ef9b4c746c
commit
4e1b415614
4 changed files with 74 additions and 16 deletions
|
|
@ -78,7 +78,15 @@ 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 respostaComuns.erro("Consulta não retornou json válido", [texto])
|
||||
}
|
||||
} catch (erro) {
|
||||
console.error(erro)
|
||||
return respostaComuns.erroInterno({
|
||||
|
|
@ -149,12 +157,13 @@ 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 respostaComuns.erro("Consulta não retornou json válido", [
|
||||
await r.text(),
|
||||
r.statusText,
|
||||
texto,
|
||||
])
|
||||
}
|
||||
})
|
||||
|
|
@ -223,7 +232,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 respostaComuns.erro("Consulta não retornou json válido", [
|
||||
texto,
|
||||
])
|
||||
}
|
||||
})
|
||||
.catch((e) =>
|
||||
respostaComuns.erro("Erro ao enviar registros", [e.message]),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue