简体   繁体   中英

Debug HTTP request in node.js Express using PhpStorm

I created a node.js Express app using PhpStorm v2021.1 ( File -> New Project -> Express ) and when I run it ( localhost:3000 ) it runs successfully.

Then I want to debug my app API that respond to a HTTP post request. So I made HTTP request as below:
http请求

Then I add new configuration as below:
http的新配置

Finally I try click to debug: 点击调试按钮

But I can not see post request URL and data, so app runs like there is no any request:
调试时

Thanks in advance

Debugging express api works fine for me; not sure what you are debugging, and what's the reason for adding Node.js run configuration to Before launch of your HTTP request configuration: a process added to Before launch has to return an exit code, the main process is waiting for its exit code to start and thus doesn't start until the first process terminates. This is the way Before launch is designed - it's supposed to be used to run some sort of pre-processing before running the main process. But bin/www app doesn't exit, it starts the server, and it has to be running to make your API work.

Please remove your Node.js config from Before launch , start it separately in debugger (by choosing bin/www run configuration and hitting Debug ) and then run your GET / POST requests to get the breakpoints in your application code hit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM