# Network
CORS error — can't call the API
Cause:
Browser security. Cross-origin API calls are blocked unless the server returns Access-Control-Allow-Origin.
Fix:
Configure CORS on the server. If you own the API, add the header to the response. For external APIs, create a proxy on your backend.
401 Unauthorized response
Cause:
Missing or invalid token. Expired token or wrong Authorization header format.
Fix:
Use the JWT decode tool to check the token's exp (expiry). Verify the header is set to Authorization: Bearer <token>.
500 Internal Server Error response
Cause:
Server-side error. The request may be triggering a bug in the server.
Fix:
Check server logs. Verify that the request body and parameters are formatted correctly.
URL with special characters causes an error
Cause:
Special characters in URLs make them malformed. Non-ASCII characters need encoding.
Fix:
Use encodeURIComponent to encode parameter values. Verify with the URL encode tool.
# Programming
fetch result is undefined
Cause:
Missing await, or await used outside an async function. fetch returns a Promise; without await the data hasn't arrived yet.
Fix:
Use await inside an async function. console.log right after res. Check the Network tab to confirm the response is returning.
JSON parse 'Unexpected token' error
Cause:
Malformed JSON. Trailing comma, single quotes, comments, or unescaped newlines.
Fix:
Use a JSON formatter tool to check syntax. Find the error position and fix it. Keys must be double-quoted.
Event listener not firing
Cause:
Element doesn't exist yet (script in <head> runs before DOM), addEventListener not attached, or event name typo.
Fix:
Place the script at the end of <body>, or wait for DOMContentLoaded. Check that querySelector isn't returning null.
# Environment
Setup error — 'command not found'
Cause:
Node.js not installed, PATH not set, or running from the wrong directory.
Fix:
Run node -v to check if Node is installed. If not, install Node.js. Use cd to navigate to the project folder. Search the exact error message.
.env values not loading
Cause:
Wrong filename, broken KEY=value format, or app not configured to read .env.
Fix:
Check the .env format. Look for extra spaces or mismatched quotes. Use .env.example as a reference.
# Frontend
CSS styles not applying
Cause:
Lower specificity, selector typo, wrong link path, or cache.
Fix:
In DevTools Elements, select the element and check which rules apply. Struck-through rules are overridden. Verify the file path (e.g. ./style.css).
Image not displaying
Cause:
Wrong path, CORS, unsupported format, or src attribute missing.
Fix:
Check for 404 in DevTools Network tab. Verify relative vs absolute path. Confirm the src attribute is correct.
# Git
Git merge conflict
Cause:
The same file was modified on different branches and conflicts on merge.
Fix:
Between <<<<<<< and ======= is your change; between ======= and >>>>>>> is theirs. Keep what you need, delete the markers, git add, then commit.