Skip to content

Commit fb461ca

Browse files
Add async call to first code example and fix env.<binding name>
1 parent 6f6970d commit fb461ca

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/content/docs/secrets-store/integrations/workers.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ import { env } from "cloudflare:workers";
140140
import ApiClient from "example-api-client";
141141

142142
// MY_SECRETS_STORE_SECRET is now usable in top-level scope
143-
let apiClient = ApiClient.new({ apiKey: env.MY_SECRETS_STORE_SECRET });
143+
const APIkey = await env.MY_SECRETS_STORE_SECRET.get()
144+
const apiClient = ApiClient.new({ apiKey: APIKey });
144145

145146
export default {
146147
fetch(req) {
@@ -155,7 +156,7 @@ export default {
155156
export default {
156157
async fetch(request, env) {
157158
// Example of using the secret safely in an API request
158-
const APIkey = await env.MY_SECRET_NAME.get()
159+
const APIkey = await env.MY_SECRETS_STORE_SECRET.get()
159160

160161
const response = await fetch("https://api.example.com/data", {
161162
headers: { "Authorization": `Bearer ${APIKey}` },

0 commit comments

Comments
 (0)