Sorry, I can't post that code. I have deleted it. I believe that I didn't use .end(). So it can be the reason.
Though there is a part of new code that works fine now:
// On POST Request Handler
function onPOST(req, res) {
let data = '';
req.on('data', d => data += d);
req.on('end', () => {
try {
let obj = JSON.parse(data);
mod = obj.mode;
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Mode Set');
} catch (err) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end(`Error: ${err}`);
}
});
}
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.
Sorry, I can't post that code. I have deleted it. I believe that I didn't use
.end()
. So it can be the reason.Though there is a part of new code that works fine now: