Vue3 components for rendering HAL (Hypertext Application Language) resources
npm install hal-layout-vueVue 3 components for rendering HAL (Hypertext Application Language) resources.
This is the Vue 3 port of hal-layout (React version).
``bash`
npm install hal-layout-vue
`vue
Author: {{ data.name }}
Loading...
Error: {{ error.message }}
`
Root component that fetches a HAL resource and provides context to children.
`vue`
profile="detailed"
view="full"
@load="onLoad"
@error="onError"
>
Props:
- uri - Resource URI (required)profile
- - Content profile for content negotiationview
- - View parameter for representation selection
Events:
- @load - Emitted when resource is loaded@error
- - Emitted when an error occurs
Slots:
- default - Content to render when loadedfallback
- - Loading stateerror
- - Error state (receives { error })
Renders embedded resources from _embedded.
`vue
{{ data.name }}
{{ data.text }}
`
Props:
- rel - Relation name in _embedded (required)
Slot Props:
- data - Resource data (without HAL metadata)halData
- - Full HAL resourceindex
- - Index in collectionisCollection
- - Whether it's a collectiontotal
- - Total count
Renders actionable links from _links.
`vue
Delete
Update
`
Props:
- rel - Relation name in _links (required)method
- - HTTP method (default: 'GET')params
- - URI template parametersbody
- - Request body for POST/PUT/PATCHas
- - Element type ('a', 'button', 'span')invalidates
- - Relations to invalidate after actionrefreshParent
- - Refresh parent after action (default: true)
Events:
- @success - Emitted on successful action@error
- - Emitted on error
Access hypermedia context within .
`vue`
Execute actions on HAL links.
`vue
`
Supports RFC 6570 URI templates:
`vue`
Search
`json``
{
"_links": {
"self": { "href": "/posts/1" },
"edit": { "href": "/posts/1" },
"delete": { "href": "/posts/1" }
},
"_embedded": {
"author": {
"_links": { "self": { "href": "/users/1" } },
"name": "John Doe"
}
},
"title": "Hello World",
"body": "This is a post."
}
- hal-layout - React version
- HAL Specification
- Ketting - HTTP client for REST APIs
MIT