Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
get nodes for cytoscape.js from other js module

I am new to JS and facing a problem using cytoscape.js I want to get data from a PG database and based on that create nodes. However, no nondes are being shown. In the following is my code. Does anyone have any tips? Many thanks!

window.addEventListener("DOMContentLoaded", my_function);
var data = [];
let pg = import('./pg.js')
let nodes = pg.my_nodes
for (node in nodes){
  if (node !== undefined && node !== []){
    data.push(node)
  }
}

function my_function() {
  var cy = (window.cy = cytoscape({
      container: document.getElementById("cy"),
      style: [{
          selector: "node",
          style: {
            content: "data(id)"
          }
        },
        {
          selector: "edge",
          style: {
            "curve-style": "bezier",
            "target-arrow-shape": "triangle"
          }
        }
      ],
      elements: {
        nodes: data, 
        edges: []
      },
      layout: {
        name: "grid"
      }
    }));
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!