This indicates your board is not able to connect to the Wi-Fi router:
It might be caused by a problem with the SSID and password you provided at lines 4 and 5 of the sketch:
Double-check to make sure those are correct. Note that the SSID must be for a 2.4 GHz access point. The Nano ESP32 board can not connect to access points that use the 5 GHz band.
I'm not sure what is going on here. The code you provided compiles without any error for me so it seems that this error was produced when you were compiling a different version of the code.
You are reporting two completely different problems at the same time here. There is the runtime problem of the board not being able to connect to the router, and then there is the compile time problem of the sketch not compiling due to invalid syntax. It is very strange to report both in the same post because you can't upload a sketch if it doesn't compile so the program that is running on your board when it fails to connect to the router must not have been produced from the code you were attempting to compile when you got those compilation errors.