etherpad-lite-client-js icon indicating copy to clipboard operation
etherpad-lite-client-js copied to clipboard

type error at createSession

Open nise opened this issue 11 years ago • 6 comments

Hello,

thank you for your quick reply last time. I managed to run the module until I tried to create a session. Unfortunatly I cannot figure out any reason for that error in your code.

Thats the error:

/node_modules/etherpad-lite-client/main.js:63 return callback({ ^ TypeError: string is not a function at IncomingMessage. (/home/abb/Documents/www2/e2script/node_modules/etherpad-lite-client/main.js:63:20) at IncomingMessage.EventEmitter.emit (events.js:117:20) at _stream_readable.js:920:16 at process._tickCallback (node.js:415:13)

nise avatar Oct 31 '14 00:10 nise

Please provide more information

JohnMcLear avatar Oct 31 '14 00:10 JohnMcLear

From nested calls I get a groupID and a new generated autherID (a.LZZ74fyMq9imQcLs). GroupID exists. The timestamp was put in statically.

etherpad.createAuthor( req.user.username, function(err, author){ etherpad.createSession(groupID, author.authorID, 1414077328212, function(err, data){ // some code console.log(123); }); });

nise avatar Oct 31 '14 01:10 nise

etherpad.createAuthor( req.user.username, function(err, author){
  console.log("author", author, "groupID", groupID); // make sure these are defined
  etherpad.createSession(groupID, author.authorID, 1414077328212, function(err, data){
    // some code
    console.log(123);
  });
});

JohnMcLear avatar Oct 31 '14 09:10 JohnMcLear

yes, both authorID and grouID are defined. I think the problem lays in the way the two functions are nested. I could not find a solution for my problem, but it seems to related to the "closure in a loop"-problem.

nise avatar Nov 01 '14 03:11 nise

oh, it was so simple and not a bug. In contrast to the API the client needs an object containing the parameters: var args = { groupID: the_group.ep_group_id, authorID: author.authorID, validUntil: Date.now()+4_60_60 }; etherpad.createSession(args, function(err, data){ ....

Maybe the error message could be explain issues like that a little bit better.

nise avatar Nov 01 '14 03:11 nise

Please update the read me with a nested example then close the issue ----- Reply message ----- From: "niels seidel" [email protected] To: "tomassedovic/etherpad-lite-client-js" [email protected] Cc: "John McLear" [email protected] Subject: [etherpad-lite-client-js] type error at createSession (#12) Date: Sat, Nov 1, 2014 03:49

oh, it was so simple and not a bug. In contrast to the API the client needs an object containing the parameters: var args = { groupID: the_group.ep_group_id, authorID: author.authorID, validUntil: Date.now()+4_60_60 }; etherpad.createSession(args, function(err, data){ ....

Maybe the error message could be explain issues like that a little bit better.

— Reply to this email directly or view it on GitHubhttps://github.com/tomassedovic/etherpad-lite-client-js/issues/12#issuecomment-61357113.

JohnMcLear avatar Nov 01 '14 11:11 JohnMcLear