This commit is contained in:
Benjamin Toby 2024-07-13 12:01:15 +01:00
parent dfbd4c3557
commit 779881ec6e

View File

@ -116,7 +116,7 @@ async function get({ key, db, query, queryValues, tableName }) {
path: encodeURIComponent(path), path: encodeURIComponent(path),
}; };
console.log("requestObject =>", requestObject); console.log("scheme =>", scheme);
(scheme?.match(/^http$/i) ? http : https) (scheme?.match(/^http$/i) ? http : https)
.request( .request(
@ -135,7 +135,14 @@ async function get({ key, db, query, queryValues, tableName }) {
}); });
response.on("end", function () { response.on("end", function () {
resolve(JSON.parse(str)); try {
resolve(JSON.parse(str));
} catch (error) {
reject({
error: error.message,
result: str,
});
}
}); });
response.on("error", (err) => { response.on("error", (err) => {