# How to use environment variables in custom code with fetch (for FormData upload)

**URL:** https://community.neutrinos.com/t/how-to-use-environment-variables-in-custom-code-with-fetch-for-formdata-upload/1228
**Category:** Neutrinos Platform
**Tags:** neutrinos-alpha
**Created:** [September 9, 2025, 1:05pm UTC](https://community.neutrinos.com/t/how-to-use-environment-variables-in-custom-code-with-fetch-for-formdata-upload/1228 "2025-09-09T13:05:47Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Shamil](https://community.neutrinos.com/letter_avatar_proxy/v4/letter/s/73ab20/32.png) [@Shamil](https://community.neutrinos.com/u/Shamil)
#### Post date: [September 9, 2025, 1:05pm UTC](https://community.neutrinos.com/t/how-to-use-environment-variables-in-custom-code-with-fetch-for-formdata-upload/1228/1 "2025-09-09T13:05:47Z")

</div>

Hi all,

In our project, we have a document upload scenario where we must use fetch in custom code because the API expects multipart/form-data and ap.http does not handle FormData correctly.

The challenge is that with fetch we are currently forced to hardcode the API URL.

Is there a way to retrieve environment variables (e.g., MVL\_WF\_BE\_URL) in custom code so we can keep the URLs dynamic, the same way ap.http uses them?

Any guidance or examples would be much appreciated.

— Thanks in advance!

---

<div class="post-metadata">

### Author: ![Ziyad](https://community.neutrinos.com/user_avatar/community.neutrinos.com/ziyad/32/343_2.png) [@Ziyad](https://community.neutrinos.com/u/Ziyad)
#### Post date: [September 9, 2025, 1:18pm UTC](https://community.neutrinos.com/t/how-to-use-environment-variables-in-custom-code-with-fetch-for-formdata-upload/1228/2 "2025-09-09T13:18:14Z")

</div>

Hi,

You can access environment variables in your custom code using the following syntax:

```auto
const apiUrl = window.environments.MVL_WF_BE_URL;

```

Thanks,

---

<div class="post-metadata">

### Author: ![Shamil](https://community.neutrinos.com/letter_avatar_proxy/v4/letter/s/73ab20/32.png) [@Shamil](https://community.neutrinos.com/u/Shamil)
#### Post date: [September 10, 2025, 6:59am UTC](https://community.neutrinos.com/t/how-to-use-environment-variables-in-custom-code-with-fetch-for-formdata-upload/1228/3 "2025-09-10T06:59:02Z")

</div>

@ziyad getting undefined

---

<div class="post-metadata">

### Author: ![Edward](https://community.neutrinos.com/letter_avatar_proxy/v4/letter/e/90db22/32.png) [@Edward](https://community.neutrinos.com/u/Edward)
#### Post date: [August 11, 2026, 5:44pm UTC](https://community.neutrinos.com/t/how-to-use-environment-variables-in-custom-code-with-fetch-for-formdata-upload/1228/4 "2026-08-11T17:44:53Z")

</div>

Am using the same code but getting undefined. @Ziyad
