I am testing the basic helloWorld example, and it is always hitting the error return. This is what I am getting:
There was an error =( { code: 200, status: 'OK', data: { FunctionName: 'helloWorld', Revision: 2, FunctionResult: { messageValue: 'Potato' }, Logs: [ [Object], [Object] ], ExecutionTimeSeconds: 0.0001904, ProcessorTimeSeconds: 0, MemoryConsumedBytes: 2344, APIRequestsIssued: 0, HttpRequestsIssued: 0 } }
And the code printing that is:
function OnCloudHelloWorld(response: any, error: any) { if (error) { //console.log(PlayFab.GenerateErrorReport(error));\ console.log('There was an error =('); console.log(error); return; } const result = response.data.FunctionResult; console.log(JSON.stringify(result)); console.log(result['messageValue']); // note how "messageValue" directly corresponds to the JSON values set in Cloud Script }
The cloud script (I modified it to return potato):
handlers.helloWorld = function (args, context) { // The pre-defined "currentPlayerId" variable is initialized to the PlayFab ID of the player logged-in on the game client. // Cloud Script handles authenticating the player automatically. var message = "Hello " + currentPlayerId + "!"; // You can use the "log" object to write out debugging statements. It has // three functions corresponding to logging level: debug, info, and error. These functions // take a message string and an optional object. log.info(message); var inputValue = null; if (args && args.inputValue) inputValue = args.inputValue; log.debug("helloWorld:", { input: args.inputValue }); // The value you return from a Cloud Script function is passed back // to the game client in the ExecuteCloudScript API response, along with any log statements // and additional diagnostic information, such as any errors returned by API calls or external HTTP // requests. They are also included in the optional player_executed_cloudscript PlayStream event // generated by the function execution. // (https://api.playfab.com/playstream/docs/PlayStreamEventModels/player/player_executed_cloudscript) return { messageValue: 'Potato' }; //return { messageValue: message }; };
Not sure why it is doing this?