Variables
Some apps need to store and retrieve data (ex: api token). To enable the development of such apps, we provide a variables for apps to set (store) and get (retrieve) variable. Also, variable can be deleted when it is no longer required.
#
Set variableapp.variables.set(key, value)
- Stores the key, value pair in the variables store. UTF-8 characters are supported. If an entry with the key is already present, then the value will be updated.
Example
let key = "apikey";let value = "xxxx-xxxx-xxx";app.variables .set(key, value) // will return Javascript Promise .then(() => { // variable successfully set }) .catch((error) => { // error in set variable });
#
Get variableapp.variables.get(key)
- Is used to retrieve variable value. If the retrieval is successful, the value can be accessed using the data parameter in the .then function.
Example
let key = "apikey";app.variables .get(key) // will return Javascript Promise .then((data) => { // data is "xxxx-xxxx-xxx" }) .catch((error) => { // error in get variable });
#
Delete variableapp.variables.delete(key)
- Is used to delete stored variable that is no longer needed.
Example
let key = "apikey";app.variables .delete(key) // will return Javascript Promise .then(() => { // variable successfully deleted }) .catch((error) => { // error in delete variable });