I'm using nextjs API routes in my next app, and I have some code that runs when I send a POST request.
If the code that runs in the API route has errors or doesn't work right, I can't debug it because I can't use something like console.log
to see what's happening because it won't log to the frontend page. Is there some alternative?
Maybe it would be in the network tab or involve throwing errors or sending something, I'm not sure.
I'm using nextjs API routes in my next app, and I have some code that runs when I send a POST request.
If the code that runs in the API route has errors or doesn't work right, I can't debug it because I can't use something like console.log
to see what's happening because it won't log to the frontend page. Is there some alternative?
Maybe it would be in the network tab or involve throwing errors or sending something, I'm not sure.
Share Improve this question edited Dec 25, 2022 at 2:33 Nora Söderlund 1,2014 silver badges18 bronze badges asked Dec 25, 2022 at 0:11 Hudson EtkinHudson Etkin 2972 gold badges4 silver badges9 bronze badges 4-
console.log
will log in your terminal, just take a look there! – Evert Commented Dec 25, 2022 at 0:12 -
7
I believe the OP is indicating that the standard
console.log
doesn't seem to work properly in the new App Routerroute.ts
setup. Server standard out doesn't show anything at the terminal when invokingconsole.log
in a POST method. I too am having this same problem. – bencodesall Commented Jul 12, 2023 at 21:20 - @bencodesall did you find a solution to the problem? – Nikolai Commented Oct 1, 2023 at 0:20
- No answer, but I believe there was some wonky IoC/DI that was obfuscating the logging. Switched to using a DI'd Logger and solved the immediate need. – bencodesall Commented Oct 10, 2023 at 18:10
1 Answer
Reset to default 3NextJS's server will log to the terminal that's running npm run dev
this isn't within the browser.
Try look there and see if it shows.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745178443a4615306.html
评论列表(0条)