diff --git a/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js b/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js index 1dd05c8c..a9974c7c 100644 --- a/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js +++ b/packages/bruno-app/src/components/ResponsePane/QueryResult/index.js @@ -3,6 +3,7 @@ import CodeEditor from 'components/CodeEditor'; import { useTheme } from 'providers/Theme'; import { useDispatch } from 'react-redux'; import { sendRequest } from 'providers/ReduxStore/slices/collections/actions'; +import { getContentTypeHeader } from 'utils/common'; import StyledWrapper from './StyledWrapper'; @@ -18,11 +19,16 @@ const QueryResult = ({ item, collection, value, width, disableRunEventListener } } dispatch(sendRequest(item, collection.uid)); }; - + var responseType = getContentTypeHeader(item.response.headers); + let mode = 'application/json';//TODO: What to default??? json probbaly + if(responseType.includes("xml")){ + mode = "application/xml"; + } + console.log(responseType); return (
- +
); diff --git a/packages/bruno-app/src/utils/common/index.js b/packages/bruno-app/src/utils/common/index.js index f11c972d..ef8f151b 100644 --- a/packages/bruno-app/src/utils/common/index.js +++ b/packages/bruno-app/src/utils/common/index.js @@ -51,8 +51,16 @@ export const safeStringifyJSON = (obj, indent=false) => { } } +export const getContentTypeHeader = (headers) => { + let header = headers.find((element) => element[0]=='content-type'); + if(header && header[1]){ + return header[1]; + } + return ''; +} + export const formatResponse = (response) => { - var type = response.headers.find((element) => element[0]=='content-type')[1]; + var type = getContentTypeHeader(response.headers); if(type.includes("json")){ return safeStringifyJSON(response.data); }if(type.includes("xml")){