# Syntax error in Function node

**URL:** <https://discourse.nodered.org/t/syntax-error-in-function-node/90186>\
**Category:** General\
**Tags:** function-node\
**Created:** [15 August 2024 07:22 UTC](https://discourse.nodered.org/t/syntax-error-in-function-node/90186 "2024-08-15T07:22:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![martonpeter1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/martonpeter1/32/89604_2.png) [@martonpeter1](https://discourse.nodered.org/u/martonpeter1)\
**Post date:** [15 August 2024 07:22 UTC](https://discourse.nodered.org/t/syntax-error-in-function-node/90186/1 "2024-08-15T07:22:21Z")

</div>

I have dowloaded data from my Ewelink Thermostat (TRVZB), where the state of the thermostat stored in "thermostat-mode" object. Im unable to get or transfer this data to my global variable, because the hyphen in the name not accepted.  
Any solution?  
Peter

---

<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:** [15 August 2024 07:46 UTC](https://discourse.nodered.org/t/syntax-error-in-function-node/90186/2 "2024-08-15T07:46:35Z")

</div>

1. Use a change node instead of a function node.
2. Use square bracket notation instead of dot notation.

---

<div class="post-metadata">

**Author:** ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)\
**Post date:** [15 August 2024 07:47 UTC](https://discourse.nodered.org/t/syntax-error-in-function-node/90186/3 "2024-08-15T07:47:37Z")

</div>

You can either quote it or place in between square brackets. For example:

```auto
obj = {
   "thermostat-mode": xyz
}

```

or

```auto
mode = obj["thermostat-mode"]

```

---

<div class="post-metadata">

**Author:** ![martonpeter1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/martonpeter1/32/89604_2.png) [@martonpeter1](https://discourse.nodered.org/u/martonpeter1)\
**Post date:** [15 August 2024 08:07 UTC](https://discourse.nodered.org/t/syntax-error-in-function-node/90186/4 "2024-08-15T08:07:35Z")

</div>

Thanks!  
In the meantime I found the answer in "Use an object with a hyphen in a function" topic. Same like OMRID advice.

Thanks again your time and quick answer.

Peter

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [23 August 2024 22:24 UTC](https://discourse.nodered.org/t/syntax-error-in-function-node/90186/5 "2024-08-23T22:24:10Z")

</div>

(You should make the thread as `solved` to show it has been answered.)

---

<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:** [6 September 2024 22:25 UTC](https://discourse.nodered.org/t/syntax-error-in-function-node/90186/6 "2024-09-06T22:25:06Z")

</div>

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