# NNH Noob need help ;)

**URL:** <https://discourse.nodered.org/t/nnh-noob-need-help/4360>\
**Category:** General\
**Created:** [28 October 2018 16:01 UTC](https://discourse.nodered.org/t/nnh-noob-need-help/4360 "2018-10-28T16:01:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![root](https://avatars.discourse-cdn.com/v4/letter/r/cc9497/32.png) [@root](https://discourse.nodered.org/u/root)\
**Post date:** [28 October 2018 16:01 UTC](https://discourse.nodered.org/t/nnh-noob-need-help/4360/1 "2018-10-28T16:01:10Z")

</div>

I am using node red with iobroker. I have a problem with passing a flow to iobroker. **[error] [function:extractData] Function tried to send a message of type string**

```
function:extractData:
    /*
returns:
1. travelDurationTraffic in min
2. travelDuration in min
3. traveDelay in min
4. trafficJam boolean
5. trafficCongestion string
6. travelDistance in km
7. msg object (for debugging and return to the loop)
*/
var travelDurationTraffic = Math.ceil(msg.payload.resourceSets[0].resources[0].travelDurationTraffic / 60);
var travelDuration = Math.ceil(msg.payload.resourceSets[0].resources[0].travelDuration / 60);

var shortname = msg.name+":"+msg.payload.resourceSets[0].resources[0].routeLegs[0].description+"/"+msg.payload.resourceSets[0].resources[0].travelDistance+" km";

var msgTraffic = [
    {
        topic: msg.topic_prefix + ".name",
        payload: msg.name
    },
    {
        topic: msg.topic_prefix + ".travelDurationTraffic",
        payload: travelDurationTraffic
    },
    {    
        topic: msg.topic_prefix + ".travelDuration",
        payload: travelDuration
    },
    {    
        topic: msg.topic_prefix + ".travelDelay",
        payload: travelDurationTraffic - travelDuration
    },
    {    
        topic: msg.topic_prefix + ".trafficJam",
        payload: (travelDurationTraffic - travelDuration >= msg.threshold)
    },
    {    
        topic: msg.topic_prefix + ".trafficCongestion",
        payload: msg.payload.resourceSets[0].resources[0].trafficCongestion
    },
    {    
        topic: msg.topic_prefix + ".travelDistance",
        payload: msg.payload.resourceSets[0].resources[0].travelDistance
    },
    {    
        topic: msg.topic_prefix + ".travelDescription",
        payload: msg.payload.resourceSets[0].resources[0].routeLegs[0].description
    }
];

return [shortname,msgTraffic,msg.payload.resourceSets[0].resources[0].routeLegs,msg];

```

can also post the complete flow if necessary.  
the flow isn't from me  
I am total beginner so please tell for beginner 🙂

---

<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:** [28 October 2018 16:15 UTC](https://discourse.nodered.org/t/nnh-noob-need-help/4360/2 "2018-10-28T16:15:08Z")

</div>

Function nodes must always pass complete messages not just values such as strings (hence the error message). Therefore the return at the end must either return a message or an array of messages. Some of your values returned are not messages.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [28 October 2018 16:15 UTC](https://discourse.nodered.org/t/nnh-noob-need-help/4360/3 "2018-10-28T16:15:17Z")

</div>

you can’t return variables, you need to return javascript objects
