# Lacking Knowledge - Templating JavaScript Object

**URL:** <https://discourse.nodered.org/t/lacking-knowledge-templating-javascript-object/90240>\
**Category:** General\
**Created:** [18 August 2024 00:41 UTC](https://discourse.nodered.org/t/lacking-knowledge-templating-javascript-object/90240 "2024-08-18T00:41:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Unpuertomex](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/unpuertomex/32/655_2.png) [@Unpuertomex](https://discourse.nodered.org/u/Unpuertomex)\
**Post date:** [18 August 2024 00:41 UTC](https://discourse.nodered.org/t/lacking-knowledge-templating-javascript-object/90240/1 "2024-08-18T00:41:20Z")

</div>

I've been trying to figure out how to capture one of the keys further down the path but with little success. I'm able to identify the key by copying the path from the debug results but when I add it to the template node regardless of the format it doesn't produce the the result. Not sure I'm making much sense. Below is an example the flow I'm working on. Any help will be appreciated.

```auto
[
    {
        "id": "49f374582343a1c1",
        "type": "inject",
        "z": "068dbd0dd6f5efda",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 220,
        "y": 2680,
        "wires": [
            [
                "d0cd8b20cc109835"
            ]
        ]
    },
    {
        "id": "d0cd8b20cc109835",
        "type": "http request",
        "z": "068dbd0dd6f5efda",
        "name": "weather.gov",
        "method": "GET",
        "ret": "obj",
        "paytoqs": "ignore",
        "url": "https://api.weather.gov/alerts?point=32.861500,-97.278750",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 390,
        "y": 2680,
        "wires": [
            [
                "9e2b8e2697d425b8"
            ]
        ]
    },
    {
        "id": "9e2b8e2697d425b8",
        "type": "json",
        "z": "068dbd0dd6f5efda",
        "name": "",
        "property": "payload",
        "action": "obj",
        "pretty": false,
        "x": 550,
        "y": 2680,
        "wires": [
            [
                "7dbf393e637b03dd"
            ]
        ]
    },
    {
        "id": "c1e156bb3fbd11d4",
        "type": "debug",
        "z": "068dbd0dd6f5efda",
        "name": "debug 11",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 880,
        "y": 2680,
        "wires": []
    },
    {
        "id": "7dbf393e637b03dd",
        "type": "template",
        "z": "068dbd0dd6f5efda",
        "name": "",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "{{payload.title}} and {{payload.features[0].properties.event}}",
        "output": "str",
        "x": 720,
        "y": 2680,
        "wires": [
            [
                "c1e156bb3fbd11d4"
            ]
        ]
    }
]

```

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [18 August 2024 04:40 UTC](https://discourse.nodered.org/t/lacking-knowledge-templating-javascript-object/90240/2 "2024-08-18T04:40:10Z")

</div>

It seems bizarre but the template node does not recognise array indices.  
Try

```auto
{{payload.title}} and {{payload.features.0.properties.event}}

```

See [https://discourse.nodered.org/t/how-to-access-array-element-by-index-in-mustache-in-template-node/26588/3](https://discourse.nodered.org/t/how-to-access-array-element-by-index-in-mustache-in-template-node/26588/3)

---

<div class="post-metadata">

**Author:** ![Unpuertomex](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/unpuertomex/32/655_2.png) [@Unpuertomex](https://discourse.nodered.org/u/Unpuertomex)\
**Post date:** [18 August 2024 11:57 UTC](https://discourse.nodered.org/t/lacking-knowledge-templating-javascript-object/90240/3 "2024-08-18T11:57:04Z")

</div>

That was it, not sure how I missed that posting in my search, but it did the trick. Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [1 September 2024 11:57 UTC](https://discourse.nodered.org/t/lacking-knowledge-templating-javascript-object/90240/4 "2024-09-01T11:57:50Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
