I'm not sure what exactly is happening, but it may be that onInit() gets called before the networking code is fully initialized. The following will do what you're looking for:
var http = require("http");
function server() {
http.createServer(function (req, res) {
res.writeHead(200);
res.end("Hello World");
}).listen(8080);
}
function onInit() {
Serial2.write("onInit\n");
setTimeout(server, 1000);
}
The Serial2.write appears on uart1 (as opposed to the normal uart0) where the log messages are. You can remove that, I used it to see when onInit runs.
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.
I'm not sure what exactly is happening, but it may be that onInit() gets called before the networking code is fully initialized. The following will do what you're looking for:
The Serial2.write appears on uart1 (as opposed to the normal uart0) where the log messages are. You can remove that, I used it to see when onInit runs.