queryRecord()
Fetches a single record from the server without an ID (GET /{resource}).
Unlike findRecord, no ID is appended to the URL - the server is expected to
return a single object (e.g. the current user’s profile, a singleton resource).
Kind: global function
Returns: Object | Promise - Reactive request hash (default) or Axios Promise when autoResolve: false.
Throws:
ErrorIfresourceis not a registered collection.
| Param | Type | Default | Description |
|---|---|---|---|
| resource | string | The resource name / collection name. | |
| [params] | Object | | Query parameters appended to the request URL. |
| [config] | RequestConfig | | Request configuration options. |
Example
// Reactive
const result = ARM.queryRecord('addresses', { 'filter[id]': 123 }, { alias: 'currentAddress' })
result.isLoading // true while fetching
result.data // CollectionRecord once resolvedExample
// Awaitable
await ARM.queryRecord('profile', {}, { autoResolve: false })Last updated on