ishanmehta17 / knowledge_graph_cytoscape

4 stars 7 forks source link

Doesn't work in Safari of Firefox #1

Open rdmpage opened 1 year ago

rdmpage commented 1 year ago

Hi @ishanmehta17 I read your Medium article and Visualize Knowledge Graphs using cytoscape.js and forked this repo. I use Safari on a Mac, and the code didn't work. I suspect Safari (and Firefox) don't support this:

import data from './data.json' assert { type: 'json' };

If I do this instead:

var knowledge_graph_json = {};

// https://javascript.info/fetch
let response = await fetch('./data.json');

if (response.ok) { // if HTTP-status is 200-299
  knowledge_graph_json = await response.json();
} else {
  alert("HTTP-Error: " + response.status);
}

then it works in Chrome, Firefox, and Safari.

ishanmehta17 commented 1 year ago

Thanks for the suggestion. I have incorporated this.