WayScript's JS editor lets you reference Variables that exist in your program. To do this, you can reference them through the inputs dictionary.
As an example, let's create a variable called "Location" and set a value of "Brooklyn, NY"
location = inputs[ "Location" ];// Or, as a JS objectlocation = inputs.Location;
More abstractly, you reference any variable with the format:
const my_var = inputs[ "<var_name>" ];
You can also output data from your JS code and turn these into variables that can be used by other Modules in your program.
You can do this with the outputs dictionary in the following format:
outputs[ "<Var Name>" ] = variable;// exampleconst currentTime = new Date();outputs[ "Date" ] = currentTime.toISOString();
If you would like to use an npm module in your code, you can declare those dependencies in the "Dependencies" field.
Declare these dependencies on separate lines, using the format you would for an npm-install command.
You can then consume these packages in your code:
const wayscript = require( 'wayscript' );wayscript.apiKey = 'YOUR_API_KEY';let programId = 1234;wayscript.runProgram( programId );