diff --git a/dist-import/pilao-de-dados/Pilao/index.js b/dist-import/pilao-de-dados/Pilao/index.js index 8d88b14..de60469 100644 --- a/dist-import/pilao-de-dados/Pilao/index.js +++ b/dist-import/pilao-de-dados/Pilao/index.js @@ -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; diff --git a/dist-require/pilao-de-dados/Pilao/index.js b/dist-require/pilao-de-dados/Pilao/index.js index b700444..00ea63c 100644 --- a/dist-require/pilao-de-dados/Pilao/index.js +++ b/dist-require/pilao-de-dados/Pilao/index.js @@ -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; diff --git a/package.json b/package.json index cec5458..64800e3 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.169.0", + "version": "0.170.0", "description": "", "main": "src/index.ts", "exports": { diff --git a/src/pilao-de-dados/Pilao/index.ts b/src/pilao-de-dados/Pilao/index.ts index cf4b3eb..3776298 100644 --- a/src/pilao-de-dados/Pilao/index.ts +++ b/src/pilao-de-dados/Pilao/index.ts @@ -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]), )