Skip to content
On this page

API 예제

rowsPath, responseFn

이미 만들어진 API의 응답결과물을 바꾸어 바로 사용합니다.

yaml
menus:
- path: pages/-0Uyeu
  name: API
pages:
- path: pages/-0Uyeu
  title: rowsPath
  blocks:
  - type: http
    name: 1. 원본
    resource: 
    axios:
      url: https://api.selectfromuser.com/sample-api/products
      method: GET
    showDownload: false
  - type: http
    name: 2. 원본 + rowsPath
    resource: 
    axios:
      url: https://api.selectfromuser.com/sample-api/products
      method: GET
    rowsPath: rows
    showDownload: false
  - type: http
    name: 3. 원본 + rowsPath + transform
    resource: 
    axios:
      url: https://api.selectfromuser.com/sample-api/products
      method: GET
    rowsPath: rows
    responseFn: |
      return rows.map(row => { 
        row.code = row.id + '-' + row.name; 
        return row
      })
    showDownload: false
  - type: http
    name: 4. 원본 + columns
    resource: 
    axios:
      url: https://api.selectfromuser.com/sample-api/products
      method: GET
    columns:
      rows:
        format: table
    showDownload: false

valueFromEnv

환경변수를 가져와 이용합니다.

yaml
menus:
- path: pages/f8CnYb
  name: 샘플2
pages:
- path: pages/f8CnYb
  title: 환경변수
  subtitle: 설정 > 환경변수에 있는 키 입니다.
  blocks:
  - type: http
    name: GET 요청을 보냅니다.
    resource: 
    axios:
      url: https://httpbin.selectfromuser.com/anything
      method: GET
      headers:
        Authorization: "Bearer {{API_KEY}}"
    params:
      - key: API_KEY
        valueFromEnv: true
    display: col-1

기타 자료들