Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Fetch Api Call with React Graph Vis #87

Open
SHASHANK9743 opened this issue Jun 15, 2020 · 2 comments
Open

Using Fetch Api Call with React Graph Vis #87

SHASHANK9743 opened this issue Jun 15, 2020 · 2 comments

Comments

@SHASHANK9743
Copy link

Hi, I am serving the data directly from an API in the specified format. I am rendering the graph inside a Class component.
the initial state is as follows
graph = {nodes : [], edges : []}

I am fetching the data inside Component Did Mount and then setting the state of the Graph.

However while rendering it always gives me the error Node with ID "some id" already exist.
Please help I have been struggling with this for a long time now.

@morenonaitana
Copy link

Did you check if the answer from your API call does not return data with twice the same ID ?

@cjdellomes
Copy link

cjdellomes commented Sep 1, 2020

@SHASHANK9743 I ran into a similar issue on one of my own projects, in which I was also fetching data to add to the graph.

I discovered that this error is thrown when a node with an image property has a nuill value before being pushed to the nodes array. This happens even if all the nodes actually have unique IDs. I got around this by setting the value to an empty string instead of null. Empty strings seem to work just fine, and result in a blank node when drawn. Not sure if this is the issue for you, but I suggest double checking this.

Below is an example object that I push onto the nodes array of my graph. If artistImage is null, the error you encountered is thrown. Again, I got around this by making sure artistImage is an empty string if there's no associated image url.

const artistNode = { id: artist.id, label: artist.name, title: artist.name, shape: "circularImage", image: artistImage };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants