# Simple repeat last msg node to re-send MQTT

**URL:** https://discourse.nodered.org/t/simple-repeat-last-msg-node-to-re-send-mqtt/4558
**Category:** General
**Created:** [4 November 2018 16:18 UTC](https://discourse.nodered.org/t/simple-repeat-last-msg-node-to-re-send-mqtt/4558 "2018-11-04T16:18:56Z")
**Posts on this page:** 1
**Showing post:** 14

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [5 November 2018 13:33 UTC](https://discourse.nodered.org/t/simple-repeat-last-msg-node-to-re-send-mqtt/4558/14 "2018-11-05T13:33:18Z")

</div>

I'm just wanting to repeat the payload regardless of topic so I've simplified it down to this  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/384a87b7941c431defad331596d8453a31aef5b7.png)

which gets generated to this

```
if ((msg['payload']) == 'RePeAt') {
  if ((context.get('repeat')) != null) {
    msg['payload'] = (context.get('repeat'));
    node.send([msg]);
  }
} else {
  context.set('repeat', (msg['payload']));
  node.send([msg]);
}
```

---

_[View the full topic](https://discourse.nodered.org/t/simple-repeat-last-msg-node-to-re-send-mqtt/4558)._
