I test for an IP address. This could probably be refined, but generally the ESP8266 connects to wifi quickly or not at all, say if the config is wrong:
if (wifi.getIP().ip != "0.0.0.0") {
// rest of your code
} else {
console.log("not connected to wifi");
}
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 test for an IP address. This could probably be refined, but generally the ESP8266 connects to wifi quickly or not at all, say if the config is wrong: