Attached code runs fine, but after moving everything into an object, by removing comments, fails with this error.
*Uncaught Error: Function "listen" not found!
at line 13 col 10
}).listen(8080);*
Got this problem on ESP32, could not test on other board. @Gordon, if this is an ESP32 only problem, please move it to that category :-)
Tested this 10 times with both options and always got same result.
var wifi = require("Wifi");var http = require("http");
var ssid = "xxxxxxx";
var password = "yyyyyyyyyyyy";
//function httpSrv(){
function init(){
var x;
wifi.connect(ssid, {password: password}, function(dt) {
http.createServer(function(req,res){
res.writeHead(200);
res.end("Hello World");
}).listen(8080);
});
}
init();
//}
//var s = new httpSrv();
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.
Attached code runs fine, but after moving everything into an object, by removing comments, fails with this error.
*Uncaught Error: Function "listen" not found!
at line 13 col 10
Got this problem on ESP32, could not test on other board. @Gordon, if this is an ESP32 only problem, please move it to that category :-)
Tested this 10 times with both options and always got same result.