Configuration

Configuration can be used to share values globally across the project. A good example would be an API key, session key, and any other variable used across multiple cloud code actions. Data is stored on the project level and never expires. Values are stored encrypted.
Configuration can be changed using the toolbelt configuration API or using the actions UI.

Code example

async payload => {

    try {
        const secret = await toolbelt
            .config
            .get('secret_key')
        // Make a GET call Check https://github.com/mzabriskie/axios for specifics
        //we use secret_key config as api key to make a request
        const result = await request.get(`https://api.themoviedb.org/3/movie/popular?api_key=${secret}`)
        //return results of api request to message
        return new Message(result.data.total_results)
    } catch (err) {
        console.log(err);
    }
}

Set a value

Storing data can be done using the toolbelt.config.set() method. Provide a key and value to save.

async payload => {

        const secret = await toolbelt
            .config
            .set('key','value')
}

Get a value

Fetch a value by key using the get() method.

async payload => {

    const secret = await toolbelt
        .config
        .get('secret_key')
}

📘

Note

If no data exists get() will return null

Removing values

Remove a specific value by key.

async payload => {
  // Remove aa specific key
  await toolbelt
    .config
    .delete('key')
}

Reference

toolbelt.config.set(key, value)

Set config

Returns: Promise - Promise that resolves with the value being set

Properties

NameTypeDescription
KeystringKey to value
ValuestringString to store

toolbelt.config.update(key, value)

Set config

Returns: Promise - Promise that resolves with the value being updated

Properties

NameTypeDescription
KeystringKey to value
ValuestringString to store

toolbelt.config.get(key)

Retrieve data from config by key.

Returns: Promise - Promise that resolved with the value being stored or null if the key does not exist

Properties

NameTypeDescription
KeystringKey used to find the data

toolbelt.config.delete(key)

Remove data from config by key

Returns: Promise - Resolves with the key of the deleted data

Properties

NameTypeDescription
KeystringKey of the data to delete