Mine did that before I just powered the Switch off and when it came back on the WiFi worked fine. I thought it was my router at 1st but literally everything else I had was working fine.
I powered it off and on, didn't help. Undocked it, didn't help. Finally I undocked it and sat literally 3 feet from my router....now it works.
Fred.