How to approach a bug in your website?
Bugs are very common and are a familiar part of any developer's journey. Every developer should mentally prepare for bugs before writing code, as they can teach you a lot more than many other experiences. When a bug occurs, you often end up reviewing your entire codebase, gaining a deeper understanding of it. So, let’s go over how to approach and solve bugs:
Step 1: Inspect
Our web browsers offer an "Inspect" option through right-click, where you can utilize various tools such as the console, network requests, and more.
Step 2: Console
After using Inspect, check the Console. It provides details about errors, including the type of error (e.g., CORS, Mongoose) and the location of the error in your code.
Step 3: Console.log
If reviewing the code and using the Console does not resolve the issue, insert console.log
statements to trace the execution and identify where the code is failing. This will help you pinpoint the problematic line. Once identified, use debugging tools to modify and fix the error.
Extra
For issues like unsaved tokens or other data-related errors, use the "Application" tab in Inspect to check Cookies and Local Storage. This helps verify whether the backend is correctly saving data to the browser.
Subscribe to my newsletter
Read articles from Ansh Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by