# HTTP response example

**URL:** <https://discourse.nodered.org/t/http-response-example/42295>\
**Category:** General\
**Created:** [9 March 2021 03:00 UTC](https://discourse.nodered.org/t/http-response-example/42295 "2021-03-09T03:00:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![henrycosta05](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henrycosta05/32/36350_2.png) [@henrycosta05](https://discourse.nodered.org/u/henrycosta05)\
**Post date:** [9 March 2021 03:00 UTC](https://discourse.nodered.org/t/http-response-example/42295/1 "2021-03-09T03:00:29Z")

</div>

Hi guys,  
I googled the best practices to implement an API patterns like headers, status code and body keys, but just found some examples.

Also I am trying to understand template node.

Appreciate any help and docs.

---

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [9 March 2021 03:24 UTC](https://discourse.nodered.org/t/http-response-example/42295/2 "2021-03-09T03:24:36Z")

</div>

So many ways to skin this cat.....

I like to use a function node for my header needs.

 ![Screenshot from 2021-03-08 22-20-12](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/3/932b75fbb8a48cc318d5659597e67313a4e05bc1.jpeg)

```auto
[{"id":"f3653817.6b169","type":"http in","z":"cdb1eebd.d2859","name":"","url":"/camera/api/server_stats_static","method":"get","upload":false,"swaggerDoc":"","x":220,"y":140,"wires":[["2917c400.ee40f4"]]},{"id":"19e7ceac.618571","type":"http response","z":"cdb1eebd.d2859","name":"","statusCode":"","headers":{},"x":910,"y":140,"wires":[]},{"id":"58c0b0e6.4c3de8","type":"function","z":"cdb1eebd.d2859","name":"headders and status code","func":"\n//msg.payload = (was already sent)\n\nmsg.statusCode = \"200\";\n\nmsg.headers = {};\nmsg.headers['X-Robots-Tag'] = \"noindex\";\nmsg.headers['no-fs-camera'] = \"true\";\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":730,"y":140,"wires":[["19e7ceac.618571"]]},{"id":"2917c400.ee40f4","type":"http request","z":"cdb1eebd.d2859","name":"Server Stats static","method":"GET","ret":"obj","paytoqs":"ignore","url":"http://127.0.0.1:8888/static.json","tls":"","persist":false,"proxy":"","authType":"","x":490,"y":140,"wires":[["58c0b0e6.4c3de8"]]}]

```

![Screenshot from 2021-03-08 22-21-20](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/3/238f012e4378ed236c02be9c8bbcfff12a8bd124.jpeg)

I also like using **headers** over parameters in the url for talking server to server.

I like to use JSON formatted objects for my payload (response) but will also use headers as well. depends on the need/use

---

<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:** [23 March 2021 03:25 UTC](https://discourse.nodered.org/t/http-response-example/42295/3 "2021-03-23T03:25:08Z")

</div>

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