Fullstack CourseLearn by building
Back to week 4

Topic

Postman + VS Code debugging

Definition

API testing tools such as Postman let you construct and replay HTTP requests independent of the frontend, while an interactive debugger attaches to a running process to pause execution and inspect state at a breakpoint.

In simpler words

Postman lets you talk to Nest directly without the React app in the way. A debugger lets you freeze Nest mid-request and look at its variables.

These are everyday tools for isolating whether a bug is frontend, backend, or a contract mismatch, before touching any code.

After this you can

  • Reproduce a bug with a request tool before assuming it is a frontend bug
  • Save and reuse a collection with cookie-based auth
  • Set a breakpoint in a Nest handler and step through it
  • Read a stack trace back to the failing line and layer

Isolate the layer before you guess

Definition

Isolating a bug means removing variables, such as frontend rendering, browser caching, and network conditions, until only the suspected layer remains, so a request tool that talks directly to Nest can confirm whether the API itself is at fault.

In simpler words

Ask whether the bug also happens outside the browser before spending an hour in React code.

If a Postman request reproduces the bug with the same status and body the frontend saw, the problem is in Nest or the data, not React state management.

If Postman succeeds but the browser fails, suspect CORS, cookie or credentials settings, a stale query cache, or a request built with the wrong payload shape.

Save requests with the exact cookie and auth flow, running a login request first with cookie saving enabled, so protected routes are reproducible without touching the UI.

Repro checklist

1. Log in via Postman (stores access_token cookie in the collection)
2. Replay the failing request with that cookie
3. Compare status and body to what the browser received
4. If identical, it is a backend or data bug. If different, it is a client-side bug.

A five-minute Postman check saves hours of guessing which layer is wrong.

Debugging Nest with VS Code

Definition

A breakpoint pauses process execution at a specified line, allowing inspection of the call stack and local variables, and stepping through subsequent lines one at a time.

In simpler words

A breakpoint freezes Nest at one line so every variable can be inspected at that exact moment.

Launch Nest in debug mode, or attach to the running development process, and set a breakpoint inside the suspected controller, service, or guard.

Step Into descends into the next function call, Step Over runs the current line without descending, and Step Out returns to the caller. Use these to walk the exact pipeline order across guards, pipes, controllers, and services.

Inspect the call stack to see which middleware, guard, or interceptor actually ran before the failure, rather than guessing from the error message alone.

Minimal attach configuration

{
  "type": "node",
  "request": "attach",
  "port": 9229,
  "restart": true
}

Attaching to a process started with an inspect flag allows setting breakpoints without restarting Nest for every change.

Reading a stack trace

Definition

A stack trace lists the sequence of function calls active when an exception was thrown, ordered from the throwing line to the original entry point, and identifies the file and line number of each frame.

In simpler words

A stack trace is a breadcrumb trail showing exactly which function called which function, ending at the line that broke.

Read top-down: the top frame is where the error was thrown, and frames below show who called what, down to the HTTP handler.

Match the throwing frame to a pipeline stage, such as a pipe validation error, a guard rejection, a service exception, or a database driver error, to know which layer owns the fix.

A stack trace pointing into a library such as TypeORM usually means the query or entity mapping is wrong upstream in application code, not inside the library itself.

Keep in mind

  • Reproduce outside the browser before debugging inside it.
  • A breakpoint beats a console log guess once more than one variable needs inspecting.
  • Read stack traces top-down and map each frame to a known pipeline stage.

Test

Check your understanding

At least 10 questions — mix of concept, syntax, practical, and logic. Score ≥ 80% (enforced by the API) to save progress.

Checking your session…

10 questions · concept 3 · syntax 2 · practical 3 · logic 2

Concept1. Which statement best defines API testing and debugging?
Syntax2. Which code-level choice matches API testing and debugging?
Practical3. A reviewer spots a bug related to API testing and debugging. What is the right fix?
Logic4. Which reasoning correctly explains API testing and debugging?
Concept5. Which boundary does correct use of API testing and debugging preserve?
Practical6. What is the safest next step when applying API testing and debugging?
Syntax7. Which implementation direction matches the rule for API testing and debugging?
Logic8. Which consequence follows from applying API testing and debugging correctly?
Concept9. Which claim about API testing and debugging is true in this Nest + Postgres monorepo?
Practical10. Which team practice best demonstrates API testing and debugging?