• 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}`);
        }
      });
    }
    
About

Avatar for Engineer @Engineer started