I have a discord bot that uploads the daily Garfield comic every morning and I want to expand it to Twitter. To reduce clutter in the already extensive server.js file I have a new file twitter.js that I run through the console for now. However, twitter.js is unable to access keys and secrets using process.env, returning undefined.
Is there something I am missing when it comes to multiple files? Any help would be greatly appreciated.
You can use a package like dotenv-safe and config it in your app file it adds all the env variables in the .env file into the process.env
link: https://github.com/rolodato/dotenv-safe
If you still can’t figure it out, share your project name so we can see the code. If your project is private, either make it public temporarily or DM me a join link. Thanks.
I did - it was just a quick example that shows it’s working with console.logs. Hopefully I can trust the community to not trash it in the time it takes @LiquidZulu to review it
Alright, I don’t know why but it is now working. I believe there must have been an issue with my ping as I am having networking problems at the moment. Thank you all for your help.