Main site

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:

  1. Navigate to the Settings page and find the Secret Variables section.
  2. Enter the name of the variable in the Key field. Choose a name that is a valid JavaScript variable identifier.
  3. Input the corresponding value in the Value field.
  4. Save your entry by clicking the Add entry button.
  5. 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.

Adding secret variables - JsRates