From fa7fd4c589b607c0975e4e4c483da36a6e85434d Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Wed, 30 Mar 2016 05:35:42 -0400 Subject: [PATCH] Update lbry.call() for Jack's JSONception fix --- js/lbry.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/js/lbry.js b/js/lbry.js index 34525badc..68c8fc175 100644 --- a/js/lbry.js +++ b/js/lbry.js @@ -10,14 +10,12 @@ lbry.call = function (method, params, callback, connectFailedCallback) { var xhr = new XMLHttpRequest; xhr.addEventListener('load', function() { - // The response from the HTTP endpoint has a "result" key containing a JSON string of the output of the JSON-RPC method itself - var method_output = JSON.parse(JSON.parse(xhr.responseText).result); + var response = JSON.parse(xhr.responseText); - if (method_output.code !== 200) { - throw new Error('Call to method ' + method + ' failed with message: ' + method_output.message); + if (response.error) { + throw new Error('Call to method ' + method + ' failed with message: ' + response.error); } - console.log(method_output.result); - callback(method_output.result); + callback(response.result); }); if (connectFailedCallback) { @@ -32,7 +30,7 @@ lbry.call = function (method, params, callback, connectFailedCallback) 'method': method, 'params': [params, ], 'id': 0 - })); + })); } //core