mirror of
https://github.com/usebruno/bruno.git
synced 2025-06-21 04:08:01 +02: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);
|
let variables = getEnvironmentVariables(this.props.collection);
|
||||||
if (!isEqual(variables, this.variables)) {
|
if (!isEqual(variables, this.variables)) {
|
||||||
this.editor.options.brunoVarInfo.variables = variables;
|
this.editor.options.brunoVarInfo.variables = variables;
|
||||||
console.log(variables);
|
|
||||||
this.addOverlay();
|
this.addOverlay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,7 +179,6 @@ export default class QueryEditor extends React.Component {
|
|||||||
addOverlay = () => {
|
addOverlay = () => {
|
||||||
let variables = getEnvironmentVariables(this.props.collection);
|
let variables = getEnvironmentVariables(this.props.collection);
|
||||||
this.variables = variables;
|
this.variables = variables;
|
||||||
console.log(variables);
|
|
||||||
|
|
||||||
defineCodeMirrorBrunoVariablesMode(variables, 'graphql');
|
defineCodeMirrorBrunoVariablesMode(variables, 'graphql');
|
||||||
this.editor.setOption('mode', 'brunovariables');
|
this.editor.setOption('mode', 'brunovariables');
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import forOwn from 'lodash/forOwn';
|
import forOwn from 'lodash/forOwn';
|
||||||
|
import { safeStringifyJSON } from 'utils/common';
|
||||||
import StyledWrapper from './StyledWrapper';
|
import StyledWrapper from './StyledWrapper';
|
||||||
|
|
||||||
const Timeline = ({ item }) => {
|
const Timeline = ({ item }) => {
|
||||||
@ -15,6 +16,8 @@ const Timeline = ({ item }) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let requestData = safeStringifyJSON(request.data);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledWrapper className="px-3 pb-4 w-full">
|
<StyledWrapper className="px-3 pb-4 w-full">
|
||||||
<div>
|
<div>
|
||||||
@ -29,9 +32,11 @@ const Timeline = ({ item }) => {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
||||||
|
{requestData ? (
|
||||||
<pre className='line request'>
|
<pre className='line request'>
|
||||||
<span className="arrow">{'>'}</span> data {request.data ? request.data : 'null'}
|
<span className="arrow">{'>'}</span> data {requestData}
|
||||||
</pre>
|
</pre>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='mt-4'>
|
<div className='mt-4'>
|
||||||
|
@ -24,3 +24,25 @@ export const waitForNextTick = () => {
|
|||||||
setTimeout(() => resolve(), 0);
|
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…
x
Reference in New Issue
Block a user