question

brendan avatar image
brendan asked

Checking for succeeded result in Cloud Script

Brendan Vanous
started a topic on Mon, 17 August 2015 at 2:52 PM

Question from a developer:

How can I check that a server API call in Cloud Script was successful? I'm thinking something like:

var response = server.GrantItems...

if (response.code == 200)

  doA()

else

  doB()

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

·
brendan avatar image
brendan answered

Best Answer
Brendan Vanous said on Mon, 17 August 2015 at 2:52 PM

Calling the Server API methods from within Cloud Script doesn't work quite the same as when you're calling from your own server, or a tool you've written. For one thing, the SecretKey isn't needed, since it's all built into Cloud Script directly (so, there's no chance of an authorization failure). When calling Server API methods from Cloud Script, the thing to do is to check the returns defined for them in the Cloud Script server guide (http://cloudscript.playfab.com/classes/server.html), and manage cases where the returned values aren't as expected (null, etc.).

Brendan


1 Comment
Brendan Vanous said on Mon, 17 August 2015 at 2:52 PM

Calling the Server API methods from within Cloud Script doesn't work quite the same as when you're calling from your own server, or a tool you've written. For one thing, the SecretKey isn't needed, since it's all built into Cloud Script directly (so, there's no chance of an authorization failure). When calling Server API methods from Cloud Script, the thing to do is to check the returns defined for them in the Cloud Script server guide (http://cloudscript.playfab.com/classes/server.html), and manage cases where the returned values aren't as expected (null, etc.).

Brendan

10 |1200

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

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.