Skip to main content
Version: 0.5.9

Dictionary()

The Dictionary constructor lets you access a specific Fastly Edge Dictionary.

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

Syntax

new Dictionary(name);

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

Parameters

Return value

A new Dictionary 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 { Dictionary } from "fastly:dictionary";

async function app (event) {
const config = new Dictionary('animals');
return new Response(config.get('cat'));
}
addEventListener("fetch", event => event.respondWith(app(event)));