![]() ![]() ![]() Try stepping through the code and stepping into methods. You can interact with it much like you would the debugger in your browser’s console. Visual Studio should now be in debug mode, paused on the breakpoint. Using Postman or your browser, send a request to the endpoint where you put the breakpoint (using the appropriate request method). Select “nodemon” from the config dropdown. (If you’re not sure where to start, try the first line of your route method.) So, we have the following development environment: Windows 10 Docker for Windows (with Hyper-V not with WSL 2) TypeScript 4.1 Node 12.17 SAM CLI 1.13.2 I've used sam init with the Hello World template to generate the initial folder structure. If you haven’t already, go into your application code and set a breakpoint. I want to be able to debug my ts file in VS Code when the related endpoint is called from Postman. You’re now able to run your Node app with the debugger. Make any adjustments needed – in this case I need to change the value of "program": "$/server.js" Select “Nodemon” (or whatever you are using to run the Node server) Go to the Debug section of Visual Studio.Ĭlick the dropdown near the green “run” arrow and select “Add Configuration…” In this example, I’ll assume you are starting your server process with nodemon, but the steps are similar if you run the server some other way–just make sure you choose the correct config options. If requests to a given endpoint are not behaving as expected, this is a good way to start fixing the problem. You can use Visual Studio’s debugging features not just to debug a particular script, but to set breakpoints while your Node.js application is running. Now in the past, in order to test REST APIs before wiring up the UI to accept the data, typically you’d have to either query the API through a terminal’s command line, or use a GUI like Insomnia or Postman (which I actually compared in a previous blog post ). ![]()
0 Comments
Leave a Reply. |