Sign In Register

How can we help you today?

Start a new topic

Cloud code "object-oriented" programming and "static methods" issue

Hi, I have been trying to make object oriented programming in the cloud code but bumped into what seems an issue. I'm trying to declare classes and members like in the following pattern.

// "Constructor"
var Person = function(...)
    // "Public properties" = ...;
    this.two = ...;

// "Static method"
Person.staticMethod = function(...)

// "Instance method"
Person.prototype.instanceMethod = function(...)

Everything saves ok, but when trying to call a "static method" as specified like in the previous pattern the request crashed, and shows the message:


  "@class": ".GameSparksErrorResponse",
  "error": {
    "errorInstanceId": "9d108188-9087-4d6e-bed2-f5f8ab54cf10",
    "message": "An unexpected error has occurred"
  "message": "An unexpected error has occurred"

 I'd want to ask, what is the correct way to declare in the cloud code "static methods"?

Not an issue, it's solved!

Only a tip for others that are making object oriented programming, only make sure syntax and identifiers are correct in the code and do not forget the semicolon at the end of the static method definition!

1 person likes this

Thanks for sharing.

Does Cloud Code support the "class" keyword? I've tried using it but receive compilation errors.

Login to post a comment