SecretStoreEntry.prototype.plaintext
▸ plaintext(): string
Returns the plaintext contents of the SecretStoreEntry instance as String.
Syntax
plaintext()
Parameters
None.
Return value
A String
Exceptions
The plaintext()
method requires its this
value to be a SecretStoreEntry
object.
If the this
value does not inherit from SecretStoreEntry.prototype
, a TypeError
is thrown.
Examples
In this example we connect to a Secret Store named 'secrets'
and retrieve a secret named 'cat-api-key'
use the value in a Request header.
/// <reference types="@fastly/js-compute" />
import { SecretStore } from "fastly:secret-store";
async function app(event) {
const secrets = new SecretStore('secrets')
const catApiKey = await secrets.get('cat-api-key')
return fetch('/api/cat', {
headers: {
'cat-api-key': catApiKey.plaintext()
}
})
}
addEventListener("fetch", (event) => event.respondWith(app(event)))