I'd be making an API call (using something like fetch) from within the ui-template
node.
If you have your API hosted in Node-RED using the http-in
/http-out
nodes, then your API call within the Vue client could handle everything, e.g.
[
{
"id": "3ae1fe5fec1d4b4f",
"type": "http in",
"z": "9c18a4bf6ab4e5c1",
"name": "",
"url": "/invoices/:invoiceNumber",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 820,
"y": 240,
"wires": [
[
"f9438d85d70dd835"
]
]
},
{
"id": "05d3b69b57dac523",
"type": "http response",
"z": "9c18a4bf6ab4e5c1",
"name": "",
"statusCode": "",
"headers": {},
"x": 1250,
"y": 240,
"wires": []
},
{
"id": "f9438d85d70dd835",
"type": "change",
"z": "9c18a4bf6ab4e5c1",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "req.params.invoiceNumber",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1080,
"y": 240,
"wires": [
[
"05d3b69b57dac523",
"84d7120f9493ce46"
]
]
},
{
"id": "d6066823247f012e",
"type": "ui-template",
"z": "9c18a4bf6ab4e5c1",
"group": "41970c5cd2a6cef0",
"page": "",
"ui": "",
"name": "",
"order": 0,
"width": 0,
"height": 0,
"head": "",
"format": "<template>\n <v-btn @click=\"loadInvoice(123)\">Make API Call</v-btn>\n <pre>{{ invoice }}</pre>\n</template>\n\n<script>\n export default {\n data() {\n // define variables available component-wide\n // (in <template> and component functions)\n return {\n invoice: null\n }\n },\n mounted() {\n // code here when the component is first loaded\n this.queryParam = this.$route.query?.hello\n },\n methods: {\n loadInvoice: async function (invoiceNumber) {\n const response = await fetch('/node-red/invoices/' + invoiceNumber)\n this.invoice = await response.json()\n }\n }\n }\n</script>",
"storeOutMessages": true,
"passthru": true,
"resendOnRefresh": true,
"templateScope": "local",
"className": "",
"x": 900,
"y": 280,
"wires": [
[]
]
},
{
"id": "84d7120f9493ce46",
"type": "debug",
"z": "9c18a4bf6ab4e5c1",
"name": "debug 378",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1270,
"y": 280,
"wires": []
},
{
"id": "41970c5cd2a6cef0",
"type": "ui-group",
"name": "API Call Example",
"page": "bbc7b44a426b2b01",
"width": "6",
"height": "1",
"order": -1,
"showTitle": true,
"className": "",
"visible": "true",
"disabled": "false"
},
{
"id": "bbc7b44a426b2b01",
"type": "ui-page",
"name": "Debugging Problems",
"ui": "c2e1aa56f50f03bd",
"path": "/problems",
"icon": "bug",
"layout": "notebook",
"theme": "129e99574def90a3",
"order": 12,
"className": "",
"visible": "true",
"disabled": "false"
},
{
"id": "c2e1aa56f50f03bd",
"type": "ui-base",
"name": "Dashboard",
"path": "/dashboard",
"showPathInSidebar": false,
"navigationStyle": "default"
},
{
"id": "129e99574def90a3",
"type": "ui-theme",
"name": "Another Theme",
"colors": {
"surface": "#000000",
"primary": "#0094ce",
"bgPage": "#f0f0f0",
"groupBg": "#ffffff",
"groupOutline": "#d9d9d9"
},
"sizes": {
"pagePadding": "6px",
"groupGap": "6px",
"groupBorderRadius": "9px",
"widgetGap": "12px"
}
}
]