Is the problem being unable to access the Internet at all, or that you intermittently are unable to access the Internet? This is very important detail.
You also need to determine if this affects your laptop connecting to the WiFi, or whether you can access any local items on the network such as the router or other networked devices, or whether this is strictly an Internet issue where you cannot access any location (or only some sites) outside of your home network.
Does the WiFi icon on the menubar show any of the WiFi bars in bold? Option-click the WiFi icon to see whether it shows an SSID, RSSID, and connected WiFi protocol. If so, then you are connected to the WiFi and must look at possible IP address issues. If not, then you may have a signal issue (laptop's antenna, laptop's WiFi card, possibly a software issue, or an issue with the router or the laptop's location with respect to the router. You can try power cycling the router, or try connecting the laptop directly to the router using an Ethernet cable.
What IP address is assigned to the laptop? If it is a 169.254.x.x and listed as self-assigned, then the problem is that macOS is not getting a valid IP address from the router. This can be caused by a macOS configuration issue with the Network settings, or some third party software interfering with the network settings, or it may be an issue with the router itself.
If you get a valid IP address (with most home routers this can be a 192.168.x.x, or 10.0.x.x), then you need to see whether you can access your router's management interface which will usually be the x.x.x.1 IP address. For example if your laptop's IP address is 192.168.1.5, then the router's management interface will most likely be 192.168.1.1. Enter the IP address into your web browser to see whether you get the router's management login page.
If the router's management page is shown with a login prompt, then you have basic network connectivity on your home network. This means your issue is accessing a network outside your home network. Usually issues here will be due to your router (try power cycling it, or you may even need to reset it to factory defaults), or your ISP, or local Internet, or possibly a software or configuration issue with the Mac (anti-virus software, cleaning/optimizer apps, third party security software, or VPN software).
If the router's management page is not displayed, try using another browser to confirm. Then try launching the browser while holding down the Shift key and open a Private window in the browser to attempt to access the router's management page. If this works, then you have an issue with the browser, possibly a browser extension. You can also try connecting while logged into a new macOS user account instead of your main macOS user account which if this works indicates the issue is with the main macOS user account. Also try booting into Safe Mode to attempt to access the router's management page. If the latter works, then you most likely have some third party software installed which is interfering with the normal operation of macOS (anti-virus software, cleaning/optimizer apps, third party security software, or VPN software).
Can you boot the online Apple Diagnostics?