# Weird Function Output

**URL:** <https://discourse.nodered.org/t/weird-function-output/30773>\
**Category:** General\
**Created:** [27 July 2020 13:50 UTC](https://discourse.nodered.org/t/weird-function-output/30773 "2020-07-27T13:50:32Z")\
**Posts on this page:** 2\
**Page:** 3

<div class="post-metadata">

**Author:** ![oncdastan](https://avatars.discourse-cdn.com/v4/letter/o/34f0e0/32.png) [@oncdastan](https://discourse.nodered.org/u/oncdastan)\
**Post date:** [5 August 2020 11:05 UTC](https://discourse.nodered.org/t/weird-function-output/30773/41 "2020-08-05T11:05:29Z")

</div>

> [@zenofmud](#):
>
> the first time the flow runs, the `trigger` node sends the contents of global.ktop but if it doesn't exist, then msg.payload will not exist and a msg is sent to the function node with no msg.payload.

I put a 5 second delay between inject and trigger. It works fine now.

> [@zenofmud](#):
>
> In the `function` node, you have `var htop` which creates the variable with nothing in it. You then write that value to the global.htop

I put the following line above the return line:

```auto
global.set('ktop',ktop);

```

> [@zenofmud](#):
>
> What will happen if any or all of global.k1, global.k2 or global.k3 doesn't exist?

I think my last reply is the answer to this. If I remove ground or signal wire, it sends a message with no payload. This is the same thing with the original problem I had. So, maybe it is related to wiring issues, since I am working with a breadboard. When I remove power, it reads 85 degrees (C).

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [5 August 2020 11:25 UTC](https://discourse.nodered.org/t/weird-function-output/30773/42 "2020-08-05T11:25:10Z")

</div>

So why not add a `switch` node to see if msg.payload exists? If it does, send it on, if it doesn't then drop it.

[Previous page](https://discourse.nodered.org/t/weird-function-output/30773.md?page=2)
