Class KiiServerCodeEntry
Represents a server side code entry in KiiCloud.
Defined in: KiiSDK.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
execute(argument, callbacks)
Execute this server code entry.
|
|
Get the entryName of this server code entry.
|
Method Detail
{Promise}
execute(argument, callbacks)
Execute this server code entry.
If argument is an empty object or not type of Object, callbacks.failure or reject callback of promise will be called.
If argument is an empty object or not type of Object, callbacks.failure or reject callback of promise will be called.
// example to use callbacks directly // Instantiate with the endpoint. var entry = Kii.serverCodeEntry("main"); // Set the custom parameters. var arg = {"username":"name_of_my_friend", "password":"password_for_my_friend"}; // Example of executing the Server Code entry.execute(arg, { success: function(entry, argument, execResult) { // do something now that the user is logged in }, failure: function(entry, argument, execResult, anErrorString) { // do something with the error response } }); // example to use Promise // Instantiate with the endpoint. var entry = Kii.serverCodeEntry("main"); // Set the custom parameters. var arg = {"username":"name_of_my_friend", "password":"password_for_my_friend"}; // Example of executing the Server Code entry.execute(arg).then( function(params) { var entry = params[0]; var argument = params[1]; var execResult = params[2]; // do something }, function(error) { // do something with the error response } );
- Parameters:
- {Object} argument
- pass to the entry of script in the cloud. If null is specified, no argument pass to the script.
- {Object} callbacks Optional
- called on completion of execution.
- {Function} callbacks.success
- callback called when operation succeeded.
1st argument: the KiiServerCodeEntry instance which this method was called on
2nd argument: the passed argument object
3rd argument: a KiiServerCodeExecResult instance - {Function} callbacks.failure
- callback called when operation failed.
1st argument: the KiiServerCodeEntry instance which this method was called on
2nd argument: the passed argument object
3rd argument: executed result, which is null
4th argument: error string
- Returns:
- {Promise} return promise object.
- fulfill callback function: function(params). params is Array instance.
- params[0] is the KiiServerCodeEntry instance which this method was called on.
- params[1] is the passed argument object.
- params[2] is a KiiServerCodeExecResult instance.
- reject callback function: function(error). error is an Error instance.
- error.target is the KiiServerCodeEntry instance which this method was called on.
- error.message
- error.argument is passed argument object.
- fulfill callback function: function(params). params is Array instance.
{String}
getEntryName()
Get the entryName of this server code entry.
- Returns:
- {String} entryName.