fix bug when object comes as a string from backend
This commit is contained in:
parent
3ca8891b32
commit
76def20d86
2 changed files with 12 additions and 8 deletions
|
|
@ -107,7 +107,6 @@ export default function GenericNode({
|
||||||
setValidationStatus(null);
|
setValidationStatus(null);
|
||||||
}
|
}
|
||||||
}, [sseData, data.id]);
|
}, [sseData, data.id]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<NodeToolbar>
|
<NodeToolbar>
|
||||||
|
|
|
||||||
|
|
@ -311,15 +311,20 @@ export function getConnectedNodes(
|
||||||
return nodes.filter((node) => node.id === targetId || node.id === sourceId);
|
return nodes.filter((node) => node.id === targetId || node.id === sourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function convertObjToArray(singleObject) {
|
export function convertObjToArray(singleObject: object | string) {
|
||||||
|
if (typeof singleObject === "string") {
|
||||||
|
singleObject = JSON.parse(singleObject);
|
||||||
|
}
|
||||||
if (Array.isArray(singleObject)) return singleObject;
|
if (Array.isArray(singleObject)) return singleObject;
|
||||||
|
|
||||||
let arrConverted: any = [];
|
let arrConverted: any[] = [];
|
||||||
for (const key in singleObject) {
|
if (typeof singleObject === "object") {
|
||||||
if (singleObject.hasOwnProperty(key)) {
|
for (const key in singleObject) {
|
||||||
const newObj = {};
|
if (Object.prototype.hasOwnProperty.call(singleObject, key)) {
|
||||||
newObj[key] = singleObject[key];
|
const newObj = {};
|
||||||
arrConverted.push(newObj);
|
newObj[key] = singleObject[key];
|
||||||
|
arrConverted.push(newObj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return arrConverted;
|
return arrConverted;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue