added timeout to get call
This commit is contained in:
parent
11f31b2e12
commit
07360f784b
2 changed files with 7 additions and 10 deletions
|
@ -17,22 +17,20 @@ module.exports = {
|
||||||
});
|
});
|
||||||
return deferred;
|
return deferred;
|
||||||
},
|
},
|
||||||
getClaim: function(uri){ // note: move to lbryApi
|
getClaim: function(uri){
|
||||||
var deferred = new Promise(function(resolve, reject){
|
var deferred = new Promise(function(resolve, reject){
|
||||||
console.log(">> making get request to lbry daemon");
|
|
||||||
axios.post('http://localhost:5279/lbryapi', {
|
axios.post('http://localhost:5279/lbryapi', {
|
||||||
"method": "get",
|
"method": "get",
|
||||||
"params": { "uri": uri }
|
"params": { "uri": uri, "timeout": 30}
|
||||||
}).then(function (getResponse) {
|
}).then(function (getResponse) {
|
||||||
console.log(">> 'get claim' success...");
|
console.log(">> 'get claim' success...");
|
||||||
//check to make sure the daemon didn't just time out (or otherwise send an error that appears to be a success?)
|
//check to make sure the daemon didn't just time out (or otherwise send an error that appears to be a success response)
|
||||||
// if (getResponse.data.result.error){
|
if (getResponse.data.result.error){
|
||||||
// reject(getResponse.data.result.error);
|
reject(getResponse.data.result.error);
|
||||||
// }
|
}
|
||||||
console.log(">> response data:", getResponse.data);
|
|
||||||
// resolve the promise with the download path for the claim we got
|
// resolve the promise with the download path for the claim we got
|
||||||
/*
|
/*
|
||||||
note: put in a check to make sure we do not resolve until the download is actually complete (total_bytes should match written_bytes)
|
note: put in a check to make sure we do not resolve until the download is actually complete (response.data.completed === true)
|
||||||
*/
|
*/
|
||||||
resolve(getResponse.data);
|
resolve(getResponse.data);
|
||||||
}).catch(function(getUriError){
|
}).catch(function(getUriError){
|
||||||
|
|
|
@ -93,7 +93,6 @@ module.exports = {
|
||||||
});
|
});
|
||||||
return deferred;
|
return deferred;
|
||||||
},
|
},
|
||||||
|
|
||||||
getClaimBasedOnUri: function(uri){
|
getClaimBasedOnUri: function(uri){
|
||||||
/*
|
/*
|
||||||
to do: need to pass the URI through a test to see if it is free and public. Right now it is jumping straight to 'get'ing and serving the asset.
|
to do: need to pass the URI through a test to see if it is free and public. Right now it is jumping straight to 'get'ing and serving the asset.
|
||||||
|
|
Loading…
Reference in a new issue