Reputation: 6915
Working on short tutorial with deno
and postgres
from https://blog.logrocket.com/creating-your-first-rest-api-with-deno-and-postgres/
I had an error within my config.js
file:
const env = Deno.env();
export const APP_HOST = env.APP_HOST || "127.0.0.1";
export const APP_PORT = env.APP_PORT || 4000;
Running deno command I got the error:
$ deno run -A index.js
error: Uncaught TypeError: Deno.env is not a function
const env = Deno.env();
Upvotes: 1
Views: 1309
Reputation: 40414
That blog post is using an older version of Deno, where Deno.env()
was a function.
It was changed for 1.0.0
release. Deno.env
is now an object with: .set
, .get
, .toObject
methods.
So to get an env variable you do:
Deno.env.get('MY_VARIABLE');
Deno introduced a lot of breaking changes for 1.0.0
release, so I suggest to avoid using code from tutorials using <1.0.0
.
Upvotes: 3
Reputation: 1074525
As the error says, Deno.env
isn't a function. So you don't use ()
on it. It's an object, you use it directly:
const env = Deno.env;
Upvotes: 0