diff --git a/packages/bruno-cli/src/runner/prepare-request.js b/packages/bruno-cli/src/runner/prepare-request.js index eab44f8c0..aaeb15441 100644 --- a/packages/bruno-cli/src/runner/prepare-request.js +++ b/packages/bruno-cli/src/runner/prepare-request.js @@ -76,10 +76,15 @@ const prepareRequest = (request, collectionRoot) => { if (!contentTypeDefined) { axiosRequest.headers['content-type'] = 'application/json'; } - const jsonBody = decomment(request.body.json); + let jsonBody; + try { + jsonBody = decomment(request?.body?.json); + } catch (error) { + jsonBody = request?.body?.json; + } try { axiosRequest.data = JSONbig.parse(jsonBody); - } catch (ex) { + } catch (error) { axiosRequest.data = jsonBody; } } diff --git a/packages/bruno-electron/src/ipc/network/prepare-request.js b/packages/bruno-electron/src/ipc/network/prepare-request.js index bd09619f4..73b8bf71c 100644 --- a/packages/bruno-electron/src/ipc/network/prepare-request.js +++ b/packages/bruno-electron/src/ipc/network/prepare-request.js @@ -172,11 +172,16 @@ const prepareRequest = (request, collectionRoot, collectionPath) => { if (!contentTypeDefined) { axiosRequest.headers['content-type'] = 'application/json'; } - const body = decomment(request.body.json); + let jsonBody; try { - axiosRequest.data = JSONbig.parse(body); - } catch (ex) { - axiosRequest.data = body; + jsonBody = decomment(request?.body?.json); + } catch (error) { + jsonBody = request?.body?.json; + } + try { + axiosRequest.data = JSONbig.parse(jsonBody); + } catch (error) { + axiosRequest.data = jsonBody; } }