I'm new to looking at gamesparks - Struggling to find many examples of some of the methods available.
Coming from a node.js and javascript background i'm struggling to see how some things pull together.
var httpSender = Spark.getHttp("http://somehost")
So i'm assuming httpSender will get the response, what if it fails?
How can I access the result?
Where is best to execute this?
I want to run everything from cloud code and happy that events are effectively classes but i'm still not quite understanding how some of the less well documented aspects such as httpRequest fit into the stack.
Thanks for your help
fraser
Best Answer
C
Customer Support
said
almost 8 years ago
Hi Fraser,
You can access most results by making them a variable, like:
//Gets a random string
var response = Spark.getHttp("http://www.random.org/strings/?num=1&len=20&digits=on&upperalpha=on&loweralpha=on&unique=on&format=plain&rnd=new").get().getResponseString();
From there you can see the data by referencing the response.
You can manipulate the data using the variable or pass it on to the Response using Spark.setScriptData like:
//Gets a random string
var response = Spark.getHttp("http://www.random.org/strings/?num=1&len=20&digits=on&upperalpha=on&loweralpha=on&unique=on&format=plain&rnd=new").get().getResponseString();
//Check for whatever their error response will be
if(response !== "404 error"){
Spark.setScriptData("Random String", response);
}
Shane
1 Comment
Customer Support
said
almost 8 years ago
Answer
Hi Fraser,
You can access most results by making them a variable, like:
//Gets a random string
var response = Spark.getHttp("http://www.random.org/strings/?num=1&len=20&digits=on&upperalpha=on&loweralpha=on&unique=on&format=plain&rnd=new").get().getResponseString();
From there you can see the data by referencing the response.
You can manipulate the data using the variable or pass it on to the Response using Spark.setScriptData like:
//Gets a random string
var response = Spark.getHttp("http://www.random.org/strings/?num=1&len=20&digits=on&upperalpha=on&loweralpha=on&unique=on&format=plain&rnd=new").get().getResponseString();
//Check for whatever their error response will be
if(response !== "404 error"){
Spark.setScriptData("Random String", response);
}
Fraser Kemp
Hi all
I'm new to looking at gamesparks - Struggling to find many examples of some of the methods available.
Coming from a node.js and javascript background i'm struggling to see how some things pull together.
var httpSender = Spark.getHttp("http://somehost")
So i'm assuming httpSender will get the response, what if it fails?
How can I access the result?
Where is best to execute this?
I want to run everything from cloud code and happy that events are effectively classes but i'm still not quite understanding how some of the less well documented aspects such as httpRequest fit into the stack.
Thanks for your help
fraser
Hi Fraser,
You can access most results by making them a variable, like:
From there you can see the data by referencing the response.
You can manipulate the data using the variable or pass it on to the Response using Spark.setScriptData like:
Shane
Customer Support
Hi Fraser,
You can access most results by making them a variable, like:
From there you can see the data by referencing the response.
You can manipulate the data using the variable or pass it on to the Response using Spark.setScriptData like:
Shane
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics