node-jsonrpc icon indicating copy to clipboard operation
node-jsonrpc copied to clipboard

A couple of issues I noticed

Open bellostom opened this issue 13 years ago • 2 comments

Hi

Just wanted to mention some issues I noticed

  1. You should add the Content-Type: application/json to the headers you send

  2. 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

bellostom avatar Dec 15 '11 08:12 bellostom

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.

zeisss avatar Dec 15 '11 11:12 zeisss

No problem.

But I think you should change the code in the examples, to reflect the current API

Thomas

bellostom avatar Dec 15 '11 12:12 bellostom