# If I am assigning response body in msg.payload than flow breaks

**URL:** <https://discourse.nodered.org/t/if-i-am-assigning-response-body-in-msg-payload-than-flow-breaks/21533>\
**Category:** General\
**Created:** [11 February 2020 07:35 UTC](https://discourse.nodered.org/t/if-i-am-assigning-response-body-in-msg-payload-than-flow-breaks/21533 "2020-02-11T07:35:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhishekjaiswalraw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/abhishekjaiswalraw/32/16377_2.png) [@abhishekjaiswalraw](https://discourse.nodered.org/u/abhishekjaiswalraw)\
**Post date:** [11 February 2020 07:35 UTC](https://discourse.nodered.org/t/if-i-am-assigning-response-body-in-msg-payload-than-flow-breaks/21533/1 "2020-02-11T07:35:49Z")

</div>

```auto
request(reqOptions, function (error, response, body) {
    node.warn(response);
    // node.warn(msg.payload);
    if(error){
        msg.publish=false;
        node.send(msg);
        node.done();
    }
    if(response.statusCode>=200 && response.statusCode<=226){
        msg.publish=true;
        msg.payload = response;
        node.send(msg);
        node.done();
    }else{
         msg.payload = response;
        msg.publish=false;
        node.send(msg);
        node.done();
    }
});
return

```

Error

```auto
11 Feb 13:00:58 - TypeError: Cannot assign to read only property 'writeQueueSize' of object '#<TCP>'
    at _clone (/home/abhishek/.nvm/versions/node/v10.15.3/lib/node_modules/node-red/node_modules/clone/clone.js:162:16)
    at _clone (/home/abhishek/.nvm/versions/node/v10.15.3/lib/node_modules/node-red/node_modules/clone/clone.js:162:18)
    at _clone (/home/abhishek/.nvm/versions/node/v10.15.3/lib/node_modules/node-red/node_modules/clone/clone.js:162:18)
    at _clone (/home/abhishek/.nvm/versions/node/v10.15.3/lib/node_modules/node-red/node_modules/clone/clone.js:162:18)
    at _clone (/home/abhishek/.nvm/versions/node/v10.15.3/lib/node_modules/node-red/node_modules/clone/clone.js:162:18)
    at clone (/home/abhishek/.nvm/versions/node/v10.15.3/lib/node_modules/node-red/node_modules/clone/clone.js:202:10)
    at Object.cloneMessage (/home/abhishek/.nvm/versions/node/v10.15.3/lib/node_modules/node-red/node_modules/@node-red/util/lib/util.js:90:13)
    at sendResults (/home/abhishek/.nvm/versions/node/v10.15.3/lib/node_modules/node-red/node_modules/@node-red/nodes/core/function/10-function.js:39:55)
    at Object.send (/home/abhishek/.nvm/versions/node/v10.15.3/lib/node_modules/node-red/node_modules/@node-red/nodes/core/function/10-function.js:122:21)
    at Object.send (Function node:58825e1f.73d0c [Create an entry]:1:313)
    at Request._callback (Function node:58825e1f.73d0c [Create an entry]:37:14)
    at Request.self.callback (/home/abhishek/.node-red/node_modules/request/request.js:185:22)
    at Request.emit (events.js:189:13)
    at Request.<anonymous> (/home/abhishek/.node-red/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:189:13)
    at IncomingMessage.<anonymous> (/home/abhishek/.node-red/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:277:13)
    at IncomingMessage.emit (events.js:194:15)
    at endReadableNT (_stream_readable.js:1125:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

```

I am using a request module inside function node

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [11 February 2020 07:55 UTC](https://discourse.nodered.org/t/if-i-am-assigning-response-body-in-msg-payload-than-flow-breaks/21533/2 "2020-02-11T07:55:04Z")

</div>

The response object is not a cloneable object. Pick out the properties you want from it and assign just those, not the whole object.

Alternatively, use the HTTP Request node so you don't have to write all this code yourself.

---

<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:** [11 April 2020 07:55 UTC](https://discourse.nodered.org/t/if-i-am-assigning-response-body-in-msg-payload-than-flow-breaks/21533/3 "2020-04-11T07:55:07Z")

</div>

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