# Function inserts '\[object Object\]' instead of it´s payload

**URL:** <https://discourse.nodered.org/t/function-inserts-object-object-instead-of-it-s-payload/37777>\
**Category:** General\
**Created:** [19 December 2020 21:57 UTC](https://discourse.nodered.org/t/function-inserts-object-object-instead-of-it-s-payload/37777 "2020-12-19T21:57:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![oma](https://avatars.discourse-cdn.com/v4/letter/o/977dab/32.png) [@oma](https://discourse.nodered.org/u/oma)\
**Post date:** [19 December 2020 21:57 UTC](https://discourse.nodered.org/t/function-inserts-object-object-instead-of-it-s-payload/37777/1 "2020-12-19T21:57:31Z")

</div>

Hi there,

for whatever reason i fail inserting the value of a msg object into a topic - he only shows '[object Object]':

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/f/6fed2420c989aaa6dec2fc6786efafc1632933e2.png)

I assume the error is within the "MakeSQL" function:

```auto
var temp = {payload: msg.payload.temperatur};
var vent = {payload: msg.payload.ventil};

msg.topic = "INSERT INTO `Markus_HO` (`ID`, `Raum`, `Temperatur`, `Timestamp`,`Ventil`) VALUES (NULL, 'Markus_HO', '"+temp+"', CURRENT_TIMESTAMP, '"+vent+"');";
return msg;

```

I am sure it´s a small thing but i can´t see it and hope for a quick: "It´s so damn easy friend: It´s..." 🙂

---

<div class="post-metadata">

**Author:** ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)\
**Post date:** [19 December 2020 22:08 UTC](https://discourse.nodered.org/t/function-inserts-object-object-instead-of-it-s-payload/37777/2 "2020-12-19T22:08:11Z")

</div>

Its because you are defining both variables as objects which have the value under a key called payload within in them. If you actually want to assign the value from the wanted message property directly to the variable in a way that can be used in string concatenation you would just have to do something like this:

```auto
var temp = msg.payload.temperatur;

```

Johannes

---

<div class="post-metadata">

**Author:** ![oma](https://avatars.discourse-cdn.com/v4/letter/o/977dab/32.png) [@oma](https://discourse.nodered.org/u/oma)\
**Post date:** [19 December 2020 23:00 UTC](https://discourse.nodered.org/t/function-inserts-object-object-instead-of-it-s-payload/37777/3 "2020-12-19T23:00:22Z")

</div>

Thanks - this does the trick after moving to `var temp = msg.payload.Temperatur; `

---

<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:** [2 January 2021 23:00 UTC](https://discourse.nodered.org/t/function-inserts-object-object-instead-of-it-s-payload/37777/4 "2021-01-02T23:00:26Z")

</div>

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