Skip to content

Commit

Permalink
handle json or text
Browse files Browse the repository at this point in the history
  • Loading branch information
keturiosakys committed Aug 27, 2024
1 parent ee1b9d3 commit 815d9bb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions frontend/src/pages/RequestDetailsPage/hooks/useReplayRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,18 @@ export function useReplayRequest({ span }: { span: OtelSpan }) {

const replayBody = useMemo(() => {
const body = getRequestBody(span);
return {
type: "json",
value: body ?? "",
};
try {
JSON.parse(body ?? "");
return {
type: "json",
value: body ?? "",
};
} catch {
return {
type: "text",
value: body ?? "",
};
}
}, [span]);

const canHaveRequestBody = useMemo<boolean>(() => {
Expand Down

0 comments on commit 815d9bb

Please sign in to comment.