# Function output payload

**URL:** <https://discourse.nodered.org/t/function-output-payload/61098>\
**Category:** General\
**Created:** [11 April 2022 06:46 UTC](https://discourse.nodered.org/t/function-output-payload/61098 "2022-04-11T06:46:34Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [11 April 2022 06:59 UTC](https://discourse.nodered.org/t/function-output-payload/61098/2 "2022-04-11T06:59:24Z")

</div>

Firstly, is there a reason you are not using [node-red-node-snmp](https://flows.nodered.org/node/node-red-node-snmp)?

Secondly, as you are running async code, you cannot `return msg` you need to use [node.send](https://nodered.org/docs/user-guide/writing-functions#sending-messages-asynchronously)

e.g....

```javascript
// NPM module exposed as variable, npm_module
const session = snmp.createSession ("192.168.10.250", "public");
const oids = ["1.3.6.1.2.1.1.1.0"];

session.get (oids, function (error, varbinds) {
    if (error) {
        node.error(error, msg);
    } else {
        for (let i = 0; i < varbinds.length; i++) {
            const e = snmp.varbindError(varbinds[i]);
            if (e) {
                node.error(e, msg);
            } else {
                msg.payload = varbinds[i].value;
                msg.topic = varbinds[i].oid;
                node.send(msg)
            }
        }
    }
    session.close ();
});

/// return msg; << delete this

```

---

_[View the full topic](https://discourse.nodered.org/t/function-output-payload/61098)._
