How to connect to TigerGraph Cloud from Node.js

I am creating a website and I want to use TigerGraph Cloud for the database. I am trying to connect to TigerGraph Cloud from a local development environment. My backend is Node.js and I am using the TigerGraph.js package to create the connection.

When I run a TigerGraph query from a Node.js endpoint I get this error:

statusCode: 404
Endpoint is not found from url = /query/<GraphName>/<queryName>, please use GET /endpoints to list all valid endpoints.

What does this mean and what do I need to do to connect to my queries?

Thank you!

Hi! Could you send your code? Make sure that your graph name and query name are correct. Here’s an example of how it should run (assuming SUBDOMAIN, GRAPHNAME, USERNAME, PASSWORD, SECRET, TOKEN, QUERYNAME, and PARAMETERS are substituted with their respective values).

const tgjs = require('tigergraph.js');

let conn = new tgjs.createTigerGraphConnection(SUBDOMAIN + ".i.tgcloud.io", GRAPHNAME, USERNAME, PASSWORD, SECRET, TOKEN);
conn.runQuery(QUERYNAME, PARAMETERS, (res) => {
    console.log(res);
    /* Do something. */
});

Here’s an example (assuming PASSWORD, SECRET, and TOKEN are substituted with the actual values).

const tgjs = require('tigergraph.js');

let conn = new tgjs.createTigerGraphConnection("pokemon.i.tgcloud.io", "PokemonGraph", "tigergraph", PASSWORD, SECRET, TOKEN);
conn.runQuery("getTypeCount", {}, (res) => {
    console.log(res);
    /* Do something. */
});

Hope this helps! Let me know if you have any questions.

1 Like