• I've stripped down my code, same error:

    const WIFI = require("Wifi");
    
    onPageRequest = function(req, res) {
      data = 'foo\nbar\\nfoo';
      res.writeHead(200, {"Content-Type": "text/text", "Content-Length": data.length});
      res.write(data);
      res.end();
    };
    
    startWifi = function() {
      WIFI.connect(ssid, {password: password}, function(err) {
        require("http").createServer(onPageReque­st).listen(80);
        console.log(WIFI.getIP());
      });
    };
    
    ssid = "myssid";
    password = "mypassword";
    startWifi();
    
    /*
    What I get:
    foo
    bar\nbar
    
    What I expected:
    foo\nbar\\nfoo
    */
    
  • Yepp, that's working as it should work. You would get the same result in every other environment with the same escaping rules. Just try it in a browser console :)
    \n is just a way to write newline character.
    To get foo\nbar\\nfoo you should write foo\\nbar\\\\nfoo.

About

Avatar for AkosLukacs @AkosLukacs started