# Function Node - need help

**URL:** <https://discourse.nodered.org/t/function-node-need-help/58941>\
**Category:** General\
**Created:** [24 February 2022 17:37 UTC](https://discourse.nodered.org/t/function-node-need-help/58941 "2022-02-24T17:37:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flixm](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/flixm/32/17122_2.png) [@Flixm](https://discourse.nodered.org/u/Flixm)\
**Post date:** [24 February 2022 17:37 UTC](https://discourse.nodered.org/t/function-node-need-help/58941/1 "2022-02-24T17:37:15Z")

</div>

Hi there,

i know i need to learn about the function node, but till now i'm working without it and i'm happy with it. TILL today with this function:

The sample shows this:

```auto
{
    "body": "Test"
}

```

But i need the input of the payload instead of "Test".

How do i need the set it ? i tried and googled for it but no success.  
Thx in advance

Felix

---

<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:** [24 February 2022 18:15 UTC](https://discourse.nodered.org/t/function-node-need-help/58941/2 "2022-02-24T18:15:39Z")

</div>

Hi, the function node needs to contain valid Javascript and if you aren't familiar, there are some excellent short courses and tutorials that will give you the basics and more.

Your post doesn't really contain enough information to help. What you've given is actually valid JSON not JavaScript. JSON is a serialisable data format closely related to but not the same as a JavaScript object.

A typical function node might look like:

```nohighlight
return {
   "body": msg.payload,
}

```

Which does very little obviously but does output a new message based on the input message.

---

<div class="post-metadata">

**Author:** ![Flixm](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/flixm/32/17122_2.png) [@Flixm](https://discourse.nodered.org/u/Flixm)\
**Post date:** [24 February 2022 19:21 UTC](https://discourse.nodered.org/t/function-node-need-help/58941/4 "2022-02-24T19:21:59Z")

</div>

Hi,  
i found out how to edit the "body" with the -change node-

thx for your answer

---

<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:** [10 March 2022 19:22 UTC](https://discourse.nodered.org/t/function-node-need-help/58941/5 "2022-03-10T19:22:54Z")

</div>

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