added timeout to get call

This commit is contained in:
bill bittner 2017-06-13 17:52:29 -07:00
parent 11f31b2e12
commit 07360f784b
2 changed files with 7 additions and 10 deletions

View file

@ -17,22 +17,20 @@ module.exports = {
});
return deferred;
},
getClaim: function(uri){ // note: move to lbryApi
getClaim: function(uri){
var deferred = new Promise(function(resolve, reject){
console.log(">> making get request to lbry daemon");
axios.post('http://localhost:5279/lbryapi', {
"method": "get",
"params": { "uri": uri }
"params": { "uri": uri, "timeout": 30}
}).then(function (getResponse) {
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?)
// if (getResponse.data.result.error){
// reject(getResponse.data.result.error);
// }
console.log(">> response data:", getResponse.data);
//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){
reject(getResponse.data.result.error);
}
// 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);
}).catch(function(getUriError){

View file

@ -93,7 +93,6 @@ module.exports = {
});
return deferred;
},
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.