# useEnv() 기능으로 안전하게 export된 환경변수 활용

**URL:** <https://ask.selectfromuser.com/t/useenv-export/274>\
**Category:** 공지사항\
**Created:** [9월 30, 2024, 1:46오후 UTC](https://ask.selectfromuser.com/t/useenv-export/274 "2024-09-30T13:46:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hbkim](https://yyz2.discourse-cdn.com/flex032/user_avatar/ask.selectfromuser.com/hbkim/32/23_2.png) [@hbkim](https://ask.selectfromuser.com/u/hbkim)\
**Post date:** [9월 30, 2024, 1:46오후 UTC](https://ask.selectfromuser.com/t/useenv-export/274/1 "2024-09-30T13:46:28Z")

</div>

환경변수 관련 기능을 추가하였습니다.

- `useEnv()`

안전하게 export된 환경변수를 requestFn, responseFn에 활용합니다.

requestFn는 아래와 같이 사용하실 수 있습니다.

```yaml
    requestFn: |
      const env = useEnv()
      console.log('current environment:', env)

```

`PUBLIC_` 으로 시작하는 환경변수를 사용할 수 있습니다.

- e.g. `PUBLIC_API_KEY`

**\<전체 YAML 예제\>**

```yaml
  blocks:
  - type: http
    axios:
      url: https://httpbin.selectfromuser.com/anything
      method: POST
    requestFn: |
      const env = useEnv()
      console.log('current environment:', env)
    actions:
      - type: http
        single: true
        axios:
          url: https://httpbin.selectfromuser.com/anything
          method: POST
        requestFn: |
          const env = useEnv()
          console.log('current environment:', env)

```

env 값을 가져올때는 아래처럼 이용해주세요.

- `env.PUBLIC_ENV`, `env.MODE`

```json
env = {
  PUBLIC_ENV: '...',
  MODE: '...'
}

```
