File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
src/content/docs/secrets-store/integrations Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -140,7 +140,8 @@ import { env } from "cloudflare:workers";
140140import 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
145146export default {
146147 fetch (req ) {
@@ -155,7 +156,7 @@ export default {
155156export 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} ` },
You can’t perform that action at this time.
0 commit comments