From a4dc09f7254773459b508f2f3fd0025aa7b04457 Mon Sep 17 00:00:00 2001 From: Tben <52448020+BenjaminToby@users.noreply.github.com> Date: Mon, 22 May 2023 11:17:04 +0100 Subject: [PATCH] updates --- package.json | 2 +- utils/post.js | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9ca42c9..eb6d051 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datasquirel", - "version": "1.1.17", + "version": "1.1.18", "description": "Cloud-based SQL data management tool", "main": "index.js", "scripts": { diff --git a/utils/post.js b/utils/post.js index 4763e4d..178eaa6 100644 --- a/utils/post.js +++ b/utils/post.js @@ -44,11 +44,26 @@ module.exports = async function ({ key, query, database }) { * @description make a request to datasquirel.com */ const httpResponse = await new Promise((resolve, reject) => { - const reqPayload = JSON.stringify({ + const reqPayloadString = JSON.stringify({ query, database, }).replace(/\n|\r|\n\r/gm, ""); + try { + JSON.parse(reqPayloadString); + } catch (error) { + console.log(error); + console.log(reqPayloadString); + + return { + success: false, + payload: null, + error: "Query object is invalid. Please Check query data values", + }; + } + + const reqPayload = reqPayloadString; + const httpsRequest = https.request( { method: "POST",