API_KEY. What will be the output if API_KEY is not set in the environment?console.log(Deno.env.get('API_KEY'))Deno.env.get returns when the variable is missing.If the environment variable is not set, Deno.env.get returns undefined. It does not throw an error or return null or an empty string.
deno.json configuration file. Which snippet correctly defines an environment variable API_SECRET with value mysecret?The correct key to set environment variables in deno.json is env. Other keys like environment, env_vars, or variables are invalid.
console.log(Deno.env.get('TOKEN')) print undefined even though you set TOKEN in your deploy dashboard environment variables?export default {
async fetch(request) {
console.log(Deno.env.get('TOKEN'));
return new Response('Hello');
}
};Deno Deploy supports Deno.env.get for dashboard environment variables. If it prints undefined, verify it was set correctly in the dashboard for the right project and redeploy the function.
Deno Deploy stores environment variables securely encrypted and injects them only into server-side code that has explicit permission to access them. They are not exposed to client-side code or passed insecurely.
GREETING is set to Hello?GREETING and returns it in the response. What will the response body be if GREETING is set to Hello in the deploy environment?export default {
async fetch(request) {
const greeting = Deno.env.get('GREETING') ?? 'Hi';
return new Response(greeting);
}
};Deno.env.get for environment variables set in the dashboard.In Deno Deploy edge functions, Deno.env.get('GREETING') returns Hello, so greeting is Hello and the response body is Hello.
