ConfigStore()
The ConfigStore
constructor lets you access a specific Fastly Edge Dictionary.
Note: Can only be used when processing requests, not during build-time initialization.
Syntax
new ConfigStore(name);
Note:
ConfigStore()
can only be constructed withnew
. Attempting to call it withoutnew
throws aTypeError
.
Parameters
name
: string- The name of the Fastly Edge Dictionary that this
ConfigStore
instance should provide access to.
- The name of the Fastly Edge Dictionary that this
Return value
A new ConfigStore
object.
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)));