Skip to main content
Version: 3.27.2

ConfigStore.prototype.get

The get() method returns the value associated with the provided key in the config-store. If the provided key does not exist in the ConfigStore then this returns null.

Syntax

get(key)

Parameters

  • key : string
    • The key to retrieve from the dictionary.

Return value

A string representing the specified ConfigStore value or null if the key does not exist in the ConfigStore

Description

Get a value for a key in the config-store. If the provided key does not exist in the ConfigStore then this returns null.

The get() method requires its this value to be a ConfigStore object.

If the this value does not inherit from ConfigStore.prototype, a TypeError is thrown.

Exceptions

  • TypeError
    • Thrown if the provided key is longer than 255 in length
    • Thrown if the provided key is an empty string

Examples

In this example we have an Edge Dictionary named "animals" and we return the "cat" entry as the response body to the client.

/// <reference types="@fastly/js-compute" />
import { ConfigStore } from "fastly:config-store";
async function app (event) {
const config = new ConfigStore('animals');
return new Response(config.get('cat'));
}
addEventListener("fetch", event => event.respondWith(app(event)));