Skip to main content
Version: 3.34.0

ConfigStore()

The ConfigStore constructor lets you access a specific Fastly Config Store.

Note: Can only be used when processing requests, not during build-time initialization.

Syntax

new ConfigStore(name);

Note: ConfigStore() can only be constructed with new. Attempting to call it without new throws a TypeError.

Parameters

  • name : string
    • Defines a config store instance using the resource link name.

Return value

A new ConfigStore object.

Exceptions

  • TypeError
    • Thrown if no Config Store exists with the provided name
    • Thrown if the provided name is longer than 255 in length
    • Thrown if the provided name is an empty string
    • Thrown if the provided name does not start with an ascii alphabetical character
    • Thrown if the provided name does not contain only ascii alphanumeric, underscore, and whitespace characters

Examples

In this example we have a resource link named "animals" (which is linked to a config store) 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)));