Is there anyway to get results/return value from Modules in Cloud code?
I have made some modules for code modularity , but currently i'm not aware of how to get a result from the module.
Thanks,
Ayyappa.
Best Answer
C
Customer Support
said
about 8 years ago
Hi Ayyappa,
In this example we'll just have a module that adds two numbers together:
Cloud Code -> Modules -> AddNumber:
function addTwoNumbers(firstNumber, secondNumber){
var answer = firstNumber + secondNumber;
return answer;
}
Then we'll create a new event called "GetNumbers":
require("AddNumber"); //This is the module you want to access
Spark.setScriptData("answer", addTwoNumbers(10, 15)); //This is the function within the module which will return the sum of the two numbers we enter
In this example we'll just have a module that adds two numbers together:
Cloud Code -> Modules -> AddNumber:
function addTwoNumbers(firstNumber, secondNumber){
var answer = firstNumber + secondNumber;
return answer;
}
Then we'll create a new event called "GetNumbers":
require("AddNumber"); //This is the module you want to access
Spark.setScriptData("answer", addTwoNumbers(10, 15)); //This is the function within the module which will return the sum of the two numbers we enter
Ayyappa R
Hi,
Is there anyway to get results/return value from Modules in Cloud code?
I have made some modules for code modularity , but currently i'm not aware of how to get a result from the module.
Thanks,
Ayyappa.
Hi Ayyappa,
In this example we'll just have a module that adds two numbers together:
Cloud Code -> Modules -> AddNumber:
Then we'll create a new event called "GetNumbers":
Which should produce a response which looks like:
Shane
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Hi Ayyappa,
In this example we'll just have a module that adds two numbers together:
Cloud Code -> Modules -> AddNumber:
Then we'll create a new event called "GetNumbers":
Which should produce a response which looks like:
Shane
Ayyappa R
Thanks Shane. I tried importing multiple modules with require. it worked pretty well and this feature is really useful!
Ayyappa R
Thanks Shane. I tried importing multiple modules with require. it worked pretty well and this feature is really useful!
-
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