# Basic Fetch Error

**URL:** <https://discourse.nodered.org/t/basic-fetch-error/22416>\
**Category:** General\
**Created:** [29 February 2020 17:17 UTC](https://discourse.nodered.org/t/basic-fetch-error/22416 "2020-02-29T17:17:17Z")\
**Posts on this page:** 1\
**Showing post:** 26

<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:** [1 March 2020 20:16 UTC](https://discourse.nodered.org/t/basic-fetch-error/22416/26 "2020-03-01T20:16:56Z")

</div>

To be honest, adding yet another dependency on an external webserver seems like one kludge too far to me.

Here's another approach that is self-contained in Node-RED: use the TCP Request node in Node-RED and do the HTTP request from scratch... I've even done the parsing of the response for you...

```auto
[{"id":"b02df2ce.532e1","type":"inject","z":"12e1febf.0d0201","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":720,"wires":[["623db68f.934af8"]]},{"id":"623db68f.934af8","type":"template","z":"12e1febf.0d0201","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"GET /query?select=%5Btime.iso,ch1.d2,ch1.amps.d2,ch1.va.d2,ch1.pf.d2%5D&begin=h-30m&end=h&group=30m&format=json&header=yes HTTP/1.1\nHost: 41.192.149.206:8080\nUser-Agent: curl/7.65.1\nAccept: */*\n\n","output":"str","x":280,"y":720,"wires":[["8e60424b.b40c8"]]},{"id":"8e60424b.b40c8","type":"tcp request","z":"12e1febf.0d0201","server":"41.192.149.206","port":"8080","out":"time","splitc":"2000","name":"","x":490,"y":720,"wires":[["408c796c.ded338","7ff73210.e471ec"]]},{"id":"408c796c.ded338","type":"function","z":"12e1febf.0d0201","name":"parse response","func":"let parts = msg.payload.toString().split(/\\r\\n\\r\\n/);\n\n// Drop the headers\nparts.shift();\n\nparts.forEach(p => {\n let lines = p.split(\"\\n\");\n if (lines[0] === '') {\n return;\n }\n let length = parseInt(lines[0],16);\n if (length === 0) {\n return;\n }\n let text = \"\";\n for (let i=1;i<lines.length;i++) {\n text+=lines[i]+\"\\n\";\n }\n text = text.substring(0,length);\n msg.payload = text;\n \n})\n\ntry {\n msg.payload = JSON.parse(msg.payload);\n} catch(err) {\n node.error(err,msg);\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":460,"y":780,"wires":[["32b925c2.1f57fa"]]},{"id":"7ff73210.e471ec","type":"debug","z":"12e1febf.0d0201","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":710,"y":720,"wires":[]},{"id":"32b925c2.1f57fa","type":"debug","z":"12e1febf.0d0201","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":780,"wires":[]}]

```

---

_[View the full topic](https://discourse.nodered.org/t/basic-fetch-error/22416)._
