mirror of
https://github.com/usebruno/bruno.git
synced 2025-01-22 13:48:41 +01:00
fix: fix json stringify bug in response timeline
This commit is contained in:
parent
dd4fecfd1c
commit
d01cada16c
@ -163,7 +163,6 @@ export default class QueryEditor extends React.Component {
|
||||
let variables = getEnvironmentVariables(this.props.collection);
|
||||
if (!isEqual(variables, this.variables)) {
|
||||
this.editor.options.brunoVarInfo.variables = variables;
|
||||
console.log(variables);
|
||||
this.addOverlay();
|
||||
}
|
||||
}
|
||||
@ -180,7 +179,6 @@ export default class QueryEditor extends React.Component {
|
||||
addOverlay = () => {
|
||||
let variables = getEnvironmentVariables(this.props.collection);
|
||||
this.variables = variables;
|
||||
console.log(variables);
|
||||
|
||||
defineCodeMirrorBrunoVariablesMode(variables, 'graphql');
|
||||
this.editor.setOption('mode', 'brunovariables');
|
||||
|
@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import forOwn from 'lodash/forOwn';
|
||||
import { safeStringifyJSON } from 'utils/common';
|
||||
import StyledWrapper from './StyledWrapper';
|
||||
|
||||
const Timeline = ({ item }) => {
|
||||
@ -15,6 +16,8 @@ const Timeline = ({ item }) => {
|
||||
});
|
||||
});
|
||||
|
||||
let requestData = safeStringifyJSON(request.data);
|
||||
|
||||
return (
|
||||
<StyledWrapper className="px-3 pb-4 w-full">
|
||||
<div>
|
||||
@ -29,9 +32,11 @@ const Timeline = ({ item }) => {
|
||||
);
|
||||
})}
|
||||
|
||||
<pre className='line request'>
|
||||
<span className="arrow">{'>'}</span> data {request.data ? request.data : 'null'}
|
||||
</pre>
|
||||
{requestData ? (
|
||||
<pre className='line request'>
|
||||
<span className="arrow">{'>'}</span> data {requestData}
|
||||
</pre>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div className='mt-4'>
|
||||
|
@ -24,3 +24,25 @@ export const waitForNextTick = () => {
|
||||
setTimeout(() => resolve(), 0);
|
||||
});
|
||||
};
|
||||
|
||||
export const safeParseJSON = (str) => {
|
||||
if(!str || !str.length || typeof str !== 'string') {
|
||||
return str;
|
||||
}
|
||||
try {
|
||||
return JSON.parse(str);
|
||||
} catch (e) {
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
export const safeStringifyJSON = (obj) => {
|
||||
if(!obj) {
|
||||
return obj;
|
||||
}
|
||||
try {
|
||||
return JSON.stringify(obj);
|
||||
} catch (e) {
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user