#Environment variable doesn't work
13 messages · Page 1 of 1 (latest)
Try importing your script as a module (add type="module" inside of the </script> tag).
Please provide code.
Also if it helps try. console.log(process.env.YOUR_ENV_VARIABLE);
Thank you guys. I can make it work just fine in my code editor and local environment. I am talking about the Scrimba editor... I am sorry for not making that clear.
@wary ember@sweet hornet
Try importing your script as a module (add type="module" inside of the </script> tag).
Yes. In the HTML file in your scrim, try this ^ suggestion. Also, share the link to your scrim if you'd like someone to take a look.
@wary emberThank you, I do that
<script src="index.js" type="module"></script>
The variable just logs undefined..
I rewrote the challenge in my vs code... That is a prime example why I usually avoid writing in the scrimba editor.. They run dependencies which I cannot see or access and the editor doesn't reflect working on real world projects.. It works in my local. So I will stick with that.
Thank you though!
..If I'd share the scrim link, anybody would have access to the environment variable. That is probably a very bad idea 😉
No, that's not how Scrimba environment variables work. Your Scrimba environment variables are kept in your Scrimba account. My Scrimba environment variables are kept in my Scrimba account. The environment variables are not included in the scrim itself; that's why Scrimba built this system.
@wary ember Well yea, that's true I guess. It would only show the assigned const ..