Hoppa till innehåll

Node properties

Examples of how to get properties from a selected node from a NodeSelector 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.

The detail of the change event of the NodeSelector contains the id of the selected node.
Make sure to use the offline version, /1/0/ of the REST-API to get the properties of the node.

App.svelte
<script>
import { Panel, NodeSelector } from '@soleil-se/config-svelte';
let properties = $state({});
async function onChange(event) {
const id = event.detail;
if (id) {
properties = await fetch(`/rest-api/1/0/${id}/properties`).then((res) => res.json());
} else {
properties = {};
}
}
</script>
<Panel>
<NodeSelector name="node" label="Sida" type="page" on:change={onChange} />
<pre>{JSON.stringify(properties, null, 2)}</pre>
</Panel>

This example will show the properties of the selected node in a NodeSelector.

Node properties example