# Nested http requests inside an http endpoint

**URL:** <https://discourse.nodered.org/t/nested-http-requests-inside-an-http-endpoint/14361>\
**Category:** General\
**Created:** [15 August 2019 16:20 UTC](https://discourse.nodered.org/t/nested-http-requests-inside-an-http-endpoint/14361 "2019-08-15T16:20:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pax](https://avatars.discourse-cdn.com/v4/letter/p/f0a364/32.png) [@pax](https://discourse.nodered.org/u/pax)\
**Post date:** [15 August 2019 16:20 UTC](https://discourse.nodered.org/t/nested-http-requests-inside-an-http-endpoint/14361/1 "2019-08-15T16:20:34Z")

</div>

I'm trying to do an http request inside an http endpoint but am running into an error:

Error: Can't set headers after they are sent

I've tried deleting msg.headers, msg,statusCode and other items on msg but I always get that error. Looking at the http nodes (not digging into the source code) it appears this should work fine - ie: they don't walk on each other variables - msg.res and msg.req shouldn't be written on - but as I said I haven't yet dug into the source of the respective http nodes recently.

I've tried saving copies of msg.res and msg.req but I get other errors..

Anyone have any guidance on what to try next?

Thanks.

---

<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:** [15 August 2019 17:30 UTC](https://discourse.nodered.org/t/nested-http-requests-inside-an-http-endpoint/14361/2 "2019-08-15T17:30:00Z")

</div>

That error is normally caused by passing two messages to the HTTP Response node for the one original request.

What does your flow look like?
