Managing Secret Variables in JsRates
JsRates provides a secure method to store sensitive data like API keys, secrets, and passwords using encrypted variables. These variables can be utilized within your code without exposing the actual information.
Storing Secret Variables
Here's how to add secret variables:
- Navigate to the Settings page and find the Secret Variables section.
- Enter the name of the variable in the Key field. Choose a name that is a valid JavaScript variable identifier.
- Input the corresponding value in the Value field.
- Save your entry by clicking the Add entry button.
- Your stored keys will be listed under the Stored keys area.
Remember, the key names should be valid JavaScript variable names to ensure they can be correctly referenced in your code.
Accessing Secret Variables in Your Code
To use a stored secret variable in your calculateShippingRates(DATA, env)
function, reference it via the env
object. For instance, to access a stored key named apiKey
, use env.apiKey
.
Updating Secret Variables
Should you need to update a key:
- Simply add a new key with the same name. This will update the stored value to the new one you've provided.