I have created an Express REST API and followed various methods to put debugger inside API callback function, but no luck. I also tried This link. Still I am not able to use debugger on API call. Any help would be appreciated.
Normally all you need to do to get such breakpoints hit is starting your Node.js run configuration in debugger and then opening <yourserver URL>/list in browser:
Related
I have a REST API that was built with Node.js and Express.js. When making an API call, how can I view which portion of the code it uses? (without me having to infer it myself by reading the code)
Reddit user BehindTheMath pointed me to the following two options: logging and breakpoints.
Console logging can work, but you'd need to add logging all over the app. Another option is to debug the app, and put breakpoints and see where it stops.
i am building a flask RESTapi and i am using postman to make http post requests to my api , i want to use the werkzeug debugger , but postman wont allow me to put in the debugging pin and debug the code from postman , what can i do ?
Never needed any debugger for postman. This is not the tool you need the long blanket of code for one endpoint to test.
It gives a good option - console. I have never experienced any trouble this simple element didn't help me so far.
I'm trying to understand how to add i18n support to loopback which is built on top of express.js.
I've installed i18n-node and have read the express.js documentation. It looks like I don't want a global state of localization because I'll be serving HTTP responses. The i18n-node documentation recommends I attach it to the request object and gives an example.
My problem is that I can't find where/how to add this code into loopback. Everywhere I try to put the app.configuration function it says that method is undefined.
I have a feeling this is a middleware addition that I want to add to the middleware.json file in the routes phase. But I don't know how to do that.
Does anybody know a good way to internationalise a loopback app (server response messages, emails going out etc.)?
As per the documentation on their Github Page. I think the configuration code is best to keep in server/boot/ folder. As these are loaded as the server start and then, can be used by other rest endpoints. Don't forget to add JSON files for translations.
I don't think there are any other requirements as LoopBack is built on top of Express and most of their codes work same.
I have express.js with ejs templating.
I can see that for first request, debugger stops at break point.
But after ejs serves page on browser, any further requests never stops at break point.
I tried lot of things in frustation -> webstorm, eclipse, node-inspector,etc
Is there some config for ejs or experss that I am missing?
Even console.log is not printing anything. I know flow works for sure.
Actually it was my bad.
I was trying to debug js in public folder which is client side js.
So i have debug using chrome developer tools instead of server side debugging.
The Heroku app i'm trying to get to work (code here):
https://github.com/heroku/facebook-template-nodejs
"Unsafe Javascript attempt to access frame with URL" errors occur when the page is loaded in chrome.
The login button takes you to facebook but does not actually log you into the app and gives the same errors.
Has anyone got this app to work on Chrome or can anyone advise as to how to patch it up?
P.S. it seems to work fine on Mozilla.
Almost certain this is a cross domain policy issue, as stated above. Generally speaking, you just need to add the correct header info to the response.
Access-Control-Allow-Origin: *
In Node, I think it is just a matter of adding it as another header in the response, using
response.writeHead
See http://nodejs.org/api/http.html#http_response_writehead_statuscode_reasonphrase_headers
Oh, and there's explicit instructions on how to do it if you're using Express. I see no reason why it can't work using plain old node then.
http://enable-cors.org/server_expressjs.html
So I looked at your link, in your case I think you just have to enter the header info prior to using any other express app methods.
As to why it works in Firefox and not Chrome, not sure. Both support CORS many versions back. Maybe you have some Chrome extension that's interfering.