NuxtN
Nuxt15mo ago
4 replies
Louie

How to access environment variables in JS files?

Hi, I'm wanting to create a service layer which fetches data from an API endpoint. Inside this file I want to get my API key and base url from my .env to use in the fetch request. However, I can't seem to access it?

What's best practice for getting my env variables outside of the Nuxt context since I can't hook into the runtimeConfig?

Thank you!!
Was this page helpful?