Update lbry.call() for Jack's JSONception fix
This commit is contained in:
parent
2f8e5873f4
commit
fa7fd4c589
1 changed files with 5 additions and 7 deletions
12
js/lbry.js
12
js/lbry.js
|
@ -10,14 +10,12 @@ lbry.call = function (method, params, callback, connectFailedCallback)
|
||||||
{
|
{
|
||||||
var xhr = new XMLHttpRequest;
|
var xhr = new XMLHttpRequest;
|
||||||
xhr.addEventListener('load', function() {
|
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 response = JSON.parse(xhr.responseText);
|
||||||
var method_output = JSON.parse(JSON.parse(xhr.responseText).result);
|
|
||||||
|
|
||||||
if (method_output.code !== 200) {
|
if (response.error) {
|
||||||
throw new Error('Call to method ' + method + ' failed with message: ' + method_output.message);
|
throw new Error('Call to method ' + method + ' failed with message: ' + response.error);
|
||||||
}
|
}
|
||||||
console.log(method_output.result);
|
callback(response.result);
|
||||||
callback(method_output.result);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (connectFailedCallback) {
|
if (connectFailedCallback) {
|
||||||
|
@ -32,7 +30,7 @@ lbry.call = function (method, params, callback, connectFailedCallback)
|
||||||
'method': method,
|
'method': method,
|
||||||
'params': [params, ],
|
'params': [params, ],
|
||||||
'id': 0
|
'id': 0
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
//core
|
//core
|
||||||
|
|
Loading…
Reference in a new issue