[v11.1.x] Revert \"Frontend: Use safe stringifier in parseBody\" (#90532)

Revert "Frontend: Use safe stringifier in parseBody" (#90522)

Revert "Frontend: Use safe stringifier in parseBody (#90047)"

This reverts commit 434f386982.

(cherry picked from commit 3559c5c297)
This commit is contained in:
Ivan Ortega Alba
2024-07-18 12:30:15 +02:00
committed by GitHub
parent 6a9fc2ac93
commit 2c8c2199a1
2 changed files with 2 additions and 21 deletions
-19
View File
@@ -10,22 +10,3 @@
export const isEmptyObject = (value: unknown): value is Record<string, never> => {
return typeof value === 'object' && value !== null && Object.keys(value).length === 0;
};
/** Stringifies an object that may contain circular references */
export function safeStringifyValue(value: unknown) {
const getCircularReplacer = () => {
const seen = new WeakSet();
return (_: string, value: object | null) => {
if (typeof value === 'object' && value !== null) {
if (seen.has(value)) {
return;
}
seen.add(value);
}
return value;
};
};
return JSON.stringify(value, getCircularReplacer());
}
+2 -2
View File
@@ -1,6 +1,6 @@
import { omitBy } from 'lodash';
import { deprecationWarning, safeStringifyValue } from '@grafana/data';
import { deprecationWarning } from '@grafana/data';
import { BackendSrvRequest } from '@grafana/runtime';
export const parseInitFromOptions = (options: BackendSrvRequest): RequestInit => {
@@ -93,7 +93,7 @@ export const parseBody = (options: BackendSrvRequest, isAppJson: boolean) => {
return options.data;
}
return isAppJson ? safeStringifyValue(options.data) : new URLSearchParams(options.data);
return isAppJson ? JSON.stringify(options.data) : new URLSearchParams(options.data);
};
export async function parseResponseBody<T>(