question

Iann Delgado Murillo avatar image
Iann Delgado Murillo asked

Why is VirtualCurrencyPrices returning null?

Hi Im trying to get the price of one of my items with cloud code but it keeps returning null all the time... Ive tested returning other variables like (ItemId, etc...) and they work. but this one doesnt

handlers.PurchaseOutfit = function (args, context) {
    var outfitID = args.outfitID;
  
  var request = server.GetCatalogItems({CatalogVersion: 0.1});
	var catalogItems = request.Catalog; 
	var length = catalogItems.length; 
  
  
  for(var i = 0; i < length; i++)
	{	
          if(catalogItems[i].ItemId == outfitID)
          {

             var priceOfOutfit = 0;
             
             priceOfOutfit = (catalogItems[i].VirtualCurrencyPrices["00"]).Value;
            			                  
            
             return { messageValue: priceOfOutfit };


          }
    }
  


};
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

You can change this line to the following format. Value is undefined. Check the API to learn more.

priceOfOutfit = catalogItems[i].VirtualCurrencyPrices["00"];

If you don’t know how to debug your CloudScript, we suggest you to use Postman. Check the doc to learn how to use it. You can call the API ExecuteCloudScript via Postman conveniently to debug the CloudScript and check the errors.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Iann Delgado Murillo avatar image Iann Delgado Murillo commented ·

Thank you so much... I had been struggling with Js. I used ur line and To debug it i just turned it into a string after and it alls good now. :)

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.