added promises to claim retrieval and sockets to claim publishing #17
1 changed files with 7 additions and 7 deletions
|
@ -40,8 +40,8 @@ function orderTopClaims(claimsListArray){
|
||||||
function getClaimWithUri(uri, resolve, reject){
|
function getClaimWithUri(uri, resolve, reject){
|
||||||
console.log(">> making get request to lbry daemon");
|
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 }
|
||||||
}
|
}
|
||||||
).then(function (getUriResponse) {
|
).then(function (getUriResponse) {
|
||||||
console.log(">> 'get claim' success...");
|
console.log(">> 'get claim' success...");
|
||||||
|
@ -65,7 +65,7 @@ function getClaimWithUri(uri, resolve, reject){
|
||||||
}
|
}
|
||||||
|
|
||||||
function findAllClaims(name, resolve, reject){
|
function findAllClaims(name, resolve, reject){
|
||||||
// abstract claim_list function to here
|
// to do: abstract claim_list function to here
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -102,9 +102,9 @@ module.exports = {
|
||||||
var deferred = new Promise(function (resolve, reject){
|
var deferred = new Promise(function (resolve, reject){
|
||||||
// 2. code to resolve or reject the promise
|
// 2. code to resolve or reject the promise
|
||||||
// make a call to the daemon to get the claims list
|
// make a call to the daemon to get the claims list
|
||||||
axios.post('http://localhost:5279/lbryapi', { // receives a promise
|
axios.post('http://localhost:5279/lbryapi', {
|
||||||
method: "claim_list",
|
"method": "claim_list",
|
||||||
params: { name: claimName }
|
"params": { "name": claimName }
|
||||||
})
|
})
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
console.log(">> 'claim_list' success");
|
console.log(">> 'claim_list' success");
|
||||||
|
@ -128,7 +128,7 @@ module.exports = {
|
||||||
var orderedPublicClaims = orderTopClaims(freePublicClaims);
|
var orderedPublicClaims = orderTopClaims(freePublicClaims);
|
||||||
// create the uri for the first (selected) claim
|
// create the uri for the first (selected) claim
|
||||||
console.log(">> ordered free public claims");
|
console.log(">> ordered free public claims");
|
||||||
var freePublicClaimUri = "lbry://" + orderedPublicClaims[0].name + "#" + orderedPublicClaims[0].claim_id;
|
var freePublicClaimUri = orderedPublicClaims[0].name + "#" + orderedPublicClaims[0].claim_id;
|
||||||
console.log(">> your free public claim URI:", freePublicClaimUri);
|
console.log(">> your free public claim URI:", freePublicClaimUri);
|
||||||
// fetch the image to display
|
// fetch the image to display
|
||||||
getClaimWithUri(freePublicClaimUri, resolve, reject);
|
getClaimWithUri(freePublicClaimUri, resolve, reject);
|
||||||
|
|
Loading…
Reference in a new issue