node-jsonrpc
node-jsonrpc copied to clipboard
A couple of issues I noticed
Hi
Just wanted to mention some issues I noticed
-
You should add the Content-Type: application/json to the headers you send
-
When you decode the server's response and you check for the result key in the object, you then call
callback(null, decoded.result);
but if you find the error key you invoke the callback as
callback(decoded.error);
Why would you send the null?
Why not just use
callback(response)
Other than these, great work
Regarding the second 2. point: I think the current way is ok. Because the callback can then look like this:
function(err, result) { ... }
which is exactly the same ways as the current node.js API looks like.
No problem.
But I think you should change the code in the examples, to reflect the current API
Thomas