ConfigStore

Classin config-store@fastly/js-compute 4.0.0View source

Class for accessing a Fastly Config Store.

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

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)));

Constructor

new ConfigStore(name: string)

Creates a new ConfigStore object, providing access to the named Config Store resource.

Parameters

name: string

The resource link name for the Config Store.

Throws

  • TypeError if no Config Store exists with the provided name.
  • TypeError if the provided name is empty, longer than 255 characters, does not start with an ASCII alphabetical character, or contains characters other than ASCII alphanumerics, underscores, and spaces.

Methods

get(key: string): string | null

Get a value for a key in the Config Store. If the provided key does not exist in the Config Store then this returns null.

Parameters

key: string

The key to retrieve.

Returns

string | null

Throws

  • TypeError if the provided key is empty or longer than 255 characters.