ConfigStore
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
TypeErrorif no Config Store exists with the provided name.TypeErrorif 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
View sourceget(key: string): string | nullGet 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
TypeErrorif the provided key is empty or longer than 255 characters.