Back
Version 7
9/14/2024
try {
await import('dotenv/config');
} catch (error) {
// Ignore if dotenv is not available or fails to import
console.log('Dotenv import failed or not available:', error.message);
}
try {
await import("jsr:@std/dotenv/load");
} catch (error) {
// Ignore if @std/dotenv/load is not available or fails to import
console.log('@std/dotenv/load import failed or not available:', error.message);
}
export const env = (key) => {
let value;
if (typeof Deno !== "undefined") {
value = Deno.env.get(key);
} else if (typeof process !== "undefined" && process.env) {
value = process.env[key];
}
return value;
};
console.log("env:", env("OPENAI_API_KEY"))
Updated: September 20, 2024