# Write a variable from the vue file in the msg-variable

**URL:** <https://discourse.nodered.org/t/write-a-variable-from-the-vue-file-in-the-msg-variable/92967>\
**Category:** Developing Nodes\
**Tags:** dashboard-2\
**Created:** [7 November 2024 13:18 UTC](https://discourse.nodered.org/t/write-a-variable-from-the-vue-file-in-the-msg-variable/92967 "2024-11-07T13:18:58Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![greenDog](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@greenDog](https://discourse.nodered.org/u/greenDog)\
**Post date:** [7 November 2024 13:18 UTC](https://discourse.nodered.org/t/write-a-variable-from-the-vue-file-in-the-msg-variable/92967/1 "2024-11-07T13:18:58Z")

</div>

I have defined an array variable in the data() function in my vue file in 'export default()' and assigned a value in the processMsg function. I would now like to assign this to the msg variable in the js file so that I can view the values with a debug node.

In the debug node, however, I only get an undefiened value.

Is this possible to debug a value, which is assigned in the vue file?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 November 2024 13:39 UTC](https://discourse.nodered.org/t/write-a-variable-from-the-vue-file-in-the-msg-variable/92967/2 "2024-11-07T13:39:57Z")

</div>

Do you mean you want to send a message back to the server with the value in, or do you mean you want to log it directly from the browser? If you want to log it directly then you can use `console.log()` to show stuff in the browser developer console.

---

<div class="post-metadata">

**Author:** ![greenDog](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@greenDog](https://discourse.nodered.org/u/greenDog)\
**Post date:** [7 November 2024 13:50 UTC](https://discourse.nodered.org/t/write-a-variable-from-the-vue-file-in-the-msg-variable/92967/3 "2024-11-07T13:50:37Z")

</div>

I send the message in the js-file in the on-input event. So I want to take the array from the vue-file and assign the array to the message, which is sent in the js-file.  
If there is any other way to log the whole array it would be perfect.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 November 2024 13:53 UTC](https://discourse.nodered.org/t/write-a-variable-from-the-vue-file-in-the-msg-variable/92967/4 "2024-11-07T13:53:41Z")

</div>

> [@greenDog](#):
>
> If there is any other way to log the whole array it would be perfect.

As I said, you can use `console.log()`

---

<div class="post-metadata">

**Author:** ![greenDog](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@greenDog](https://discourse.nodered.org/u/greenDog)\
**Post date:** [7 November 2024 14:01 UTC](https://discourse.nodered.org/t/write-a-variable-from-the-vue-file-in-the-msg-variable/92967/5 "2024-11-07T14:01:13Z")

</div>

Does the console.log() or context.log() works in the vue-file?  
What arguments does the log function need? Because it doesn't works in my code.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 November 2024 14:03 UTC](https://discourse.nodered.org/t/write-a-variable-from-the-vue-file-in-the-msg-variable/92967/6 "2024-11-07T14:03:41Z")

</div>

You can put it in the js code in the functions in the vue file.

**[edit]** In `onInput` for example.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 November 2024 14:05 UTC](https://discourse.nodered.org/t/write-a-variable-from-the-vue-file-in-the-msg-variable/92967/7 "2024-11-07T14:05:45Z")

</div>

> [@greenDog](#):
>
> Does the console.log() or context.log()

Sorry, that should be `console.log()` I will correct the previous post.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [7 November 2024 22:19 UTC](https://discourse.nodered.org/t/write-a-variable-from-the-vue-file-in-the-msg-variable/92967/8 "2024-11-07T22:19:36Z")

</div>

You've tagged this with uibuilder - are you using uibuilder?

---

<div class="post-metadata">

**Author:** ![greenDog](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@greenDog](https://discourse.nodered.org/u/greenDog)\
**Post date:** [8 November 2024 07:49 UTC](https://discourse.nodered.org/t/write-a-variable-from-the-vue-file-in-the-msg-variable/92967/9 "2024-11-08T07:49:38Z")

</div>

Sorry, my mistake. I don't use uibuilder.

---

<div class="post-metadata">

**Author:** ![greenDog](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@greenDog](https://discourse.nodered.org/u/greenDog)\
**Post date:** [8 November 2024 07:52 UTC](https://discourse.nodered.org/t/write-a-variable-from-the-vue-file-in-the-msg-variable/92967/10 "2024-11-08T07:52:38Z")

</div>

How do I use console.log in the right way? It doesn't log anything in my code ☹  
The log should appear in the debug window in the node-red flow editor, right?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [8 November 2024 08:06 UTC](https://discourse.nodered.org/t/write-a-variable-from-the-vue-file-in-the-msg-variable/92967/11 "2024-11-08T08:06:48Z")

</div>

It depends where you are writing the console log. If you do in the Vue file, it will appear in the dashboards browsers developer tools console. If you do it in the nodes HTML file, it will appear in node-red browser developer tools console. If you do it in the nodes js file, it will appear in STDOUT of the node process. Typically a node does not make entries in the node-red debug sidebar. That is done by the user when they connect the output of your node to a debug node. For commissioning and debugging purposes, a node creator might add a 2nd output to the node that outputs status/debug messages.

* * *

Question. Can I make sure I understand - since you have raised this question in #Developing Nodes that you are actually developing a new UI node package, not just "using node-red"?

---

<div class="post-metadata">

**Author:** ![greenDog](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@greenDog](https://discourse.nodered.org/u/greenDog)\
**Post date:** [8 November 2024 08:47 UTC](https://discourse.nodered.org/t/write-a-variable-from-the-vue-file-in-the-msg-variable/92967/12 "2024-11-08T08:47:18Z")

</div>

I was logging in the vue file an found the log in the browsers developer tools console, thank you! 🙂  
Yes, i am working on a new UI node package 😃

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 November 2024 09:02 UTC](https://discourse.nodered.org/t/write-a-variable-from-the-vue-file-in-the-msg-variable/92967/13 "2024-11-08T09:02:05Z")

</div>

> [@greenDog](#):
>
> found the log in the browsers developer tools console

Which is exactly what I said in my first post.

---

<div class="post-metadata">

**Author:** ![greenDog](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@greenDog](https://discourse.nodered.org/u/greenDog)\
**Post date:** [8 November 2024 09:13 UTC](https://discourse.nodered.org/t/write-a-variable-from-the-vue-file-in-the-msg-variable/92967/14 "2024-11-08T09:13:39Z")

</div>

Yes, thank you. At that point I didn't know what you meant and where to find the logs of the different files...

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [8 November 2024 09:25 UTC](https://discourse.nodered.org/t/write-a-variable-from-the-vue-file-in-the-msg-variable/92967/15 "2024-11-08T09:25:11Z")

</div>

> [@greenDog](#):
>
> I don't use uibuilder

OK, I've removed the tag.

---

<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:** [22 November 2024 09:25 UTC](https://discourse.nodered.org/t/write-a-variable-from-the-vue-file-in-the-msg-variable/92967/16 "2024-11-22T09:25:55Z")

</div>

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