gremlin-javascript icon indicating copy to clipboard operation
gremlin-javascript copied to clipboard

Examples seem out of date with current execute() argument list

Open zedrdave opened this issue 8 years ago • 0 comments

After fixing the connection issue, examples still fail with this error:

TypeError: callback is not a function

Looking at the code for node-example.js, execute() is called with:

client.execute(script, function(err, res) {

However, the prototype for execute() is:

execute(script, bindings = {}, message = {}, ...args) {

Where the callback is either taken from args or from message (if message has type function).

I guess this could be fixed by adding an empty dict to the call in the example scripts (so that the callback becomes the 3rd argument) or, more elegantly, by adding a check for bindings as well as message:

   if (typeof message === 'function') {
      callback = message;
      message = {};
    }
    else if (typeof bindings === 'function') {
        callback = bindings;
        bindings = {};
    }

I'll be happy to submit a PR if that helps.

zedrdave avatar Oct 29 '16 06:10 zedrdave