# Keeping original payload data while editing it

**URL:** <https://discourse.nodered.org/t/keeping-original-payload-data-while-editing-it/94557>\
**Category:** General\
**Tags:** http-in\
**Created:** [12 January 2025 17:11 UTC](https://discourse.nodered.org/t/keeping-original-payload-data-while-editing-it/94557 "2025-01-12T17:11:32Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![lafoscony](https://avatars.discourse-cdn.com/v4/letter/l/c67d28/32.png) [@lafoscony](https://discourse.nodered.org/u/lafoscony)\
**Post date:** [12 January 2025 18:13 UTC](https://discourse.nodered.org/t/keeping-original-payload-data-while-editing-it/94557/21 "2025-01-12T18:13:23Z")

</div>

just the modified data should go to the response. the file should be the original request, with the response

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [12 January 2025 18:15 UTC](https://discourse.nodered.org/t/keeping-original-payload-data-while-editing-it/94557/22 "2025-01-12T18:15:46Z")

</div>

> [@Keeping original payload data while editing it](https://discourse.nodered.org/t/keeping-original-payload-data-while-editing-it/94557/15):
>
> Ok... You're referring to HTTP Request (that is a Node) - hence my confusion crazy_face (but I didn't have a look at the flow to be fair - so that is on me) Directly after the HTTP IN node Use a change node to store msg.payload in msg.original (use deep clone) After you make changes to payload (for the client) Respond (to client) Then to store the original incoming data, and response to a file (after you respond) use something like below const Log = { request: msg.original, res…

👆  
But in your attempt, you're setting the `payload` to `backup` in the `change` node

[![](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/1/f163fa3c1435ce1f40fc20d209bf14b13b5266a7.jpeg) ](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/1/f163fa3c1435ce1f40fc20d209bf14b13b5266a7.jpeg)

swap them around

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [12 January 2025 18:32 UTC](https://discourse.nodered.org/t/keeping-original-payload-data-while-editing-it/94557/23 "2025-01-12T18:32:52Z")

</div>

Please supply examples as asked for, so there is no ambiguity.

When you send data:0 to the in node

what object should the response get, and what object should the file get.

eg  
file

```auto
{
  "data":0,
  "body":{ 
    "sourceSummary":1,
    "errorNumbers":"errorNumbers",
    "missingNumbers":"missingNumbers"
  }
}

```

Response

```auto
{
  "data":1
}

```

Then it is clear to all

[edit]

I think you would do better with to oupts also  
e.g.

```auto
[{"id":"fa6e50458ab28f21","type":"http in","z":"667cec54c048503c","name":"","url":"/t","method":"post","upload":true,"swaggerDoc":"","x":510,"y":1880,"wires":[["ba1ab5782646f971"]]},{"id":"ba1ab5782646f971","type":"function","z":"667cec54c048503c","name":"store todo in todolist ","func":"let msgfile = {payload: RED.util.cloneMessage(msg.payload)}; // clone payload so no referencing and no res, req object\n\nlet something = {};\nsomething.data = msg.payload.data + 1\n\n// update file object\nmsgfile.payload.body = {\n sourceSummary: something.data,\n errorNumbers: \"errorNumbers\",\n missingNumbers: \"missingNumbers\"\n};\nmsg.payload.data = something.data; // set response payload to ne figure\n\nreturn [msg, msgfile]; //return the two objects to separte outputs","outputs":2,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":1880,"wires":[["4a02c0966170e3fc","79597d782ee66032"],["76545b5b7e680c59"]]},{"id":"4a02c0966170e3fc","type":"http response","z":"667cec54c048503c","name":"","statusCode":"201","headers":{},"x":920,"y":1860,"wires":[]},{"id":"79597d782ee66032","type":"debug","z":"667cec54c048503c","name":"res","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":890,"y":1800,"wires":[]},{"id":"76545b5b7e680c59","type":"debug","z":"667cec54c048503c","name":"file","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":890,"y":1920,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![lafoscony](https://avatars.discourse-cdn.com/v4/letter/l/c67d28/32.png) [@lafoscony](https://discourse.nodered.org/u/lafoscony)\
**Post date:** [14 January 2025 01:00 UTC](https://discourse.nodered.org/t/keeping-original-payload-data-while-editing-it/94557/24 "2025-01-14T01:00:00Z")

</div>

Wow I sure feel stupid. I was a sleep bit deprived and my mind was thinking you get something in and you get something out and I wanted to end on the thing I wanted out. That got me fixed thanks for the help.

---

<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:** [28 January 2025 01:00 UTC](https://discourse.nodered.org/t/keeping-original-payload-data-while-editing-it/94557/25 "2025-01-28T01:00:56Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/keeping-original-payload-data-while-editing-it/94557.md?page=1)
