From b2c28465e94d722d0d7a907f89f982cf1bafc710 Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Sun, 29 Jan 2023 13:09:33 +0530 Subject: [PATCH] fix: patch bug temporarily --- .../bruno-electron/src/ipc/network/index.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/bruno-electron/src/ipc/network/index.js b/packages/bruno-electron/src/ipc/network/index.js index e7fabbed5..3ccc45609 100644 --- a/packages/bruno-electron/src/ipc/network/index.js +++ b/packages/bruno-electron/src/ipc/network/index.js @@ -14,6 +14,22 @@ Mustache.escape = function (value) { return value; }; +const safeStringifyJSON = (data) => { + try { + return JSON.stringify(data); + } catch (e) { + return data; + } +}; + +const safeParseJSON = (data) => { + try { + return JSON.parse(data); + } catch (e) { + return data; + } +}; + const getEnvVars = (environment = {}) => { const variables = environment.variables; if (!variables || !variables.length) { @@ -68,12 +84,16 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => { } interpolateVars(request, envVars); + + // todo: + // i have no clue why electron can't send the request object + // without safeParseJSON(safeStringifyJSON(request.data)) mainWindow.webContents.send('main:http-request-sent', { requestSent: { url: request.url, method: request.method, headers: request.headers, - data: request.data + data: safeParseJSON(safeStringifyJSON(request.data)) }, collectionUid, itemUid: item.uid,