Problems getting the js reward service working

0 votes
In the 'getAllRewards:
 
var reward = JSON.parse(object);  
result = gameObj.app42.response.rewards.reward;
 
Possibly should have been:
 
var reward = JSON.parse(object);  
result = reward.app42.response.rewards.reward;
 

and also the code didn't account for just one reward being present ie. result.length == undefined

 

in the end this worked:

      rewardService.getAllRewards({
 
                success: function (object) {
                    var reward = JSON.parse(object);
                    result = reward.app42.response.rewards.reward;
                    if (result.length == undefined) {
                        console.log(result.description);
                        console.log(result.name);
                    } else
                        for (var i = 0; i < result.length; i++) {
 
                            console.log(result[i].description);
                            console.log(result[i].name);
                        }
                },
                error: function (error) {
                    console.log(result[i].description);
                }
            });
 
Is this correct or have I just created other problems?
 
Also, in getRewardByName, the 
 
console.log("rewardName is " + result.rewardName)
 
didn't work, but this did:
 
console.log("rewardName is " + result.name)

 

asked Oct 7, 2015 in App42 Cloud API-BaaS by dennis.asher (13 points)
edited Oct 7, 2015 by dennis.asher

1 Answer

+1 vote

Hello Dennis,

Greetings for the day!!!
 
Yes you are correct on all 3 accounts. Thanks for pointing it out the errors in our documentation. We will correct them as soon as possible.
 
Please let us know if you have any queries about the integration. We are here to help you.
 
Regards,
Nishant
answered Oct 7, 2015 by NishantAShephertz (30 points)
Working my way through them but about every second js example so far in js has an error or missing code. eg.

In js The
Get All Rewards By User
Get Top N Reward Earners By Group
Get Top N Reward Earners

all do not handle having just one item being returned ie. not an array
All need to check 'if (result.length == undefined) {'

etc.

Also 'Get Game Reward Points For User'
doesn't console.log the actual points. Needs:

console.log("points are" + result.points)


The api works well but lots of problems with the js examples. Makes me concerned about the serverside api code that we can't see?
Hello Dennis,

We apologies for the inconvenience cause which you faced due to the documentation issue. We have resolved all the documentation related issues for JavaScript SDK. If you face any issue while using it, please feel free to write us at support@shephertz.com.

Regarding the server side API code, you don't need to worry about that because lots of App running on our system which have large number of API requests and they have not faced any issue while using our API.

Again, Thanks for your patience.

Regards,
Himanshu Sharma
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...