I've been a Unity developer for around 6 years. I just started a new job and it has me working on some server code. I'm not used to server code and I'm pretty sure that I'm running into some very new guy problems that have me completely hung up. Maybe you guys can help?

I am asking here because I cannot see if this is a Unity issue or a JavaScript issue.

The goal is to collect information from different data tables and collect them into an array of objects that I can send back to Unity.

On my test server, I receive no errros with this code :

Code:

function loadPVPUsers( request, response)
  {      

   var dict=[];

   var players=[];
   var avatars=[];
   var username=[];
   var count=0;

   var query = new Parse.Query(Parse.Object.extend("player"));
   query.find().then(function(results)
   {
       for (var i = 0; i < results.length; i++)
       {
          var object=results[i];
          var avatar = object.get("avatarCardId");
          if(avatar!=null)
          {
             count++;
             avatars.push(avatar.id);
             players.push(object.id);
             username.push(object.get("username"));
          }
       }
    }).then(function(){
       var final=0;
       console.log(count);

       for(var i=0;i<count;i++)
       {
         var playerId = players[i];
         var uName = username[i];

          query = new Parse.Query(Parse.Object.extend("playerCards"));
         query.equalTo(players[i],avatars[i]).find().then(function(results)
         {

             dict.push({
                username : uName,
                attack : 20,
                defense : 50,
                level : 1,
                cardname : "Harold Zoidberg",
                rarity : 0,
                userID : playerId,
                });

             final++;
          }).then(function()
          {
             if(final==count)
                response.success(dict);
          });
      }
      
   });


When I run this through Unity, I receive this error “Cannot cast from source type to destination type”. On my server I receive "Result: ReferenceError: name is not defined" which I find odd because I do not have a valued called "name".

I am attempting to retrieve my data with this ParseCloud function in Unity :

Code:

ParseCloud.CallFunctionAsync<IDictionary<string,object>>("loadPVPUsers", new Dictionary<string, object>())
         .ContinueWith(t => {


I'm hoping someone can help me debug (my entire team went on vacation.) I'm sorry if this is the wrong place to ask for this? I haven't had any luck finding a good source (StackOverflow totally failed me.) If anything, could you direct me to a good location?

Thanks!