Hi @kapusticka welcome to the forum.
First things first, in order to make code more readable and importable it is important to surround your code with three backticks
```
like this
```
You can edit and correct your post by clicking the pencil icon.
See this post for more details - How to share code or flow json
Pretty much as the error says, data
is undefined yet you attempt to assigndata
to "values"
If you are passing data into the function then it's probably in msg.data or msg.payload.
Add a debug node (set to show complete message) BEFORE the function where the error occurs. Have a look for where your data is.
Ps, as you are new to node red, I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.