Removing it doesn't fix it Old C++ habits linger. The left side:
Post URL { "method": "GET", "host": "", "path": "/CMD", "pathname": "/CMD", "search": null, "port": null, "query": null } XXX /CMD Length 70 pdata= {"name":"LED1","a":0,"cmd":"pobj.a=!pobj.a;digitalWrite(LED1,pobj.a)"} pdata length= 70 { "name": "LED1", "a": 0, "cmd": "pobj.a=!pobj.a;digitalWrite(LED1,pobj.a)" } Uncaught SyntaxError: BREAK statement outside of SWITCH, FOR or WHILE loop at line 93 col 5 break; ^ Closed >
And the code with the default break commented
function doPost1(req,res){ var length; var a = url.parse(req.url, true); console.log("URL ",a); console.log("XXX ",a.pathname); length=req.headers["Content-Length"]; console.log("Length ",length); console.log("pdata= ",pdata); console.log("pdata length= ",pdata.length); switch (a.pathname){ case "/CMD": if(pdata.length==length){ pobj=JSON.parse(pdata); console.log(pobj); if(pobj.cmd !==null){ eval(pobj.cmd); pdata=JSON.stringify(pobj); res.writeHead(200); res.end(pdata); }else{ res.writeHead(201); res.end(); } //end if pobj.cmd }//endif length else break; case "/LOGdata": console.log("LOGdata= ",pdata); res.writeHead(200); res.end(pdata); break; default: res.writeHead(404); res.end(); // break; }//end switch pdata=""; }//end doPost1
@ClearMemory041063 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.
Removing it doesn't fix it
Old C++ habits linger.
The left side:
And the code with the default break commented