We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a628841 commit c787df4Copy full SHA for c787df4
src/content/docs/secrets-store/integrations/workers.mdx
@@ -99,3 +99,22 @@ export default {
99
100
### Pass `env` as an argument to `fetch`
101
102
+```js
103
+export default {
104
+ async fetch(request, env) {
105
+ // Example of using the secret safely in an API request
106
+ let response = await fetch("https://api.example.com/data", {
107
+ headers: { "Authorization": `Bearer ${env.MY_SECRETS_STORE_SECRET}` },
108
+ });
109
+
110
+ if (!response.ok) {
111
+ return new Response("Failed to fetch data", { status: response.status });
112
+ }
113
114
+ let data = await response.json();
115
+ return new Response(JSON.stringify(data), {
116
+ headers: { "Content-Type": "application/json" },
117
118
+ },
119
+};
120
+```
0 commit comments