Ok, just fixed it, there was another problem too which required a more heavy workaround.
Note that your code above will probably still break because you're not calling res.end all the time, but something like this works fine now:
res.end
function startServer() { http.createServer(function (sreq, sres) { console.log('got http request',sreq.url); sres.writeHead(200); http.get("http://www.pur3.co.uk/hello.txt", function(res) { var data = ''; console.log("Response"); res.on('data', function(d) { data += d; }); res.on('end', function() { console.log('get request ended'); sres.end(data); }); }); }).listen(80); console.log('http server started'); }
(I pulled out all the ES6 stuff just in case that happened to be a potential issue, but I'm pretty sure it's not)
@Gordon started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Ok, just fixed it, there was another problem too which required a more heavy workaround.
Note that your code above will probably still break because you're not calling
res.end
all the time, but something like this works fine now:(I pulled out all the ES6 stuff just in case that happened to be a potential issue, but I'm pretty sure it's not)