name: API
attributes:
auto:
type: boolean
behavior: Request after request changes when request.url exists.
properties:
request:
default:
url: ''
method: "GET when data is null; POST when data is present, unless explicitly set."
headers: {}
data: null
timeout: 10000
responseType: ''
response:
fields: [loading, ok, status, error, headers, responseType, result]
result:
behavior: Latest response result.
methods:
do:
signature: api.do(options)
behavior: Merge options with request and perform HTTP.request.
options:
noui: Suppress automatic error toast.
events:
response:
detail: Complete HTTP response object.
error:
detail: Error object.
rules:
- request.url is required before calling do.
- Without request.method, API uses POST when request.data is present and GET otherwise.
- Bind request with $.request when external state owns request configuration.
examples:
auto: |
do: |
tests:
- API.test.html