Skip to content

✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.

update received message structure

Aykut Saraç76b627ccc24e
diff --git a/src/pages/Widget/index.tsx b/src/pages/Widget/index.tsx
index 09054985..aa417fd8 100644
--- a/src/pages/Widget/index.tsx
+++ b/src/pages/Widget/index.tsx
@@ -39,6 +39,13 @@ function inIframe() {
}
}
+interface EmbedMessage {
+ data: {
+ json?: string;
+ options?: any;
+ };
+}
+
const WidgetPage = () => {
const [json, setJson] = React.useState(defaultJson);
const [isModalVisible, setModalVisible] = React.useState(false);
@@ -69,9 +76,10 @@ const WidgetPage = () => {
}, [collapsedNodes, collapsedEdges, loading]);
React.useEffect(() => {
- const handler = (event: { data: string }) => {
+ const handler = (event: EmbedMessage) => {
try {
- const parsedJson = JSON.stringify(parse(event.data));
+ if (!event.data?.json) return;
+ const parsedJson = JSON.stringify(parse(event.data.json));
setJson(parsedJson);
} catch (error) {
toast.error("Invalid JSON!");