Markdown
Node properties
Examples of how to get properties from a selected node from a NodeSelector based component in the current config with the REST API.
This is useful if you want to show or use properties of a node in your config.
In this example we will use a PageSelector to select a page and then fetch its properties using the REST API.
The onChange callback receives the selected node ID as its first argument. fetchRestApi uses the offline REST API by default.
<script> import { onMount } from 'svelte'; import { Panel, PageSelector } from '@soleil-se/config-svelte'; import { fetchRestApi } from '@soleil-se/config-svelte/utils';
let id = $state('') let properties = $state({});
async function fetchPageProperties() { properties = id ? await fetchRestApi(`${id}/properties`) : {}; }
onMount(() => { fetchPageProperties() });</script>
<Panel> <PageSelector name="page" label="Page" onChange={fetchPageProperties} bind:value={id} /> <pre>{JSON.stringify(properties, null, 2)}</pre></Panel>Settings
{
"URI": "/4.72eefa9418bc471993311412.html",
"URL": "https://site.com/4.72eefa9418bc471993311412.html",
"comments": [],
"createdBy": "255.62eefa9418bc471993311355",
"creationDate": 1620385687607,
"displayName": "Subpage 1",
"isActiveSubscription": false,
"jcr:mixinTypes": [
"mix:referenceable"
],
"jcr:primaryType": "sv:page",
"jcr:uuid": "4.72eefa9418bc471993311412",
"lastModifiedBy": "255.62eefa9418bc471993311355",
"lastModifiedDate": 1726549211037,
"lastPublishDate": 1726549212132,
"lastPublishedBy": "255.72eefa9418bc471993311355",
"locale": "sv",
"publishDate": 1620388304604,
"published": true,
"publishedBy": "255.72eefa9418bc471993311355",
"resourcePriority": 5,
"robotsIndex": true,
"shortId": "120",
"template": "91.72eefa9418bc47199331140c",
"usePathName": false,
"visibleCount": 0,
"visibleInMenus": true
}