Environment Variable returning undefined

I’m linking to unsplash api in my portfolio theme https://objective-montalcini-4097e2.netlify.app/ and can grab the environment variable for the access key in development without issue. But when deployed, the variable returns undefined even though I declared it in my build settings.

Is this because I’m making the get request at component level. I’m using Gatsby so i’m not sure how I would make the request at app level.

hi there, did you see this guide already? Give it a read through, and if you are still having issues, let us know.