I have a button that does some communication with the server to check if an entered value (via an input box) already exists. The code is the following: The problem is that the checkReturn call is asynchronous, and therefore the code carries on without actually waiting for the result. How do I make sure that c…
Tag: node.js
Heroku + Node: Cannot find module error
My Node app is running fine locally, but has run into an error when deploying to Heroku. The app uses Sequelize in a /models folder, which contains index.js, Company.js and Users.js. Locally, I am able to import the models using the following code in /models/index.js: This works fine, however, when I deploy t…
How do you fetch and parse xml in node.js?
How do you fetch an xml from online with node.js and parse it into a javascript object? I’ve been searching the npm register but only found how to parse the xml-string, not how to fetch it. Answer To fetch an online resource, you can use http.get(). The data can be loaded into memory, or directly sent t…
Node.js: get path from the request
I have a service called “localhost:3000/returnStat” that should take a file path as parameter. For example ‘/BackupFolder/toto/tata/titi/myfile.txt’. How can I test this service on my browser? How can I format this request using Express for instance? Answer I have not tested your code …
Node.js project naming conventions for files & folders
What are the naming conventions for files and folders in a large Node.js project? Should I capitalize, camelCase, or under-score? Ie. is this considered valid? Answer After some years with node, I can say that there are no conventions for the directory/file structure. However most (professional) express appli…
How to change selenium user agent in selenium-webdriver nodejs land?
I’m in javascript + mocha + node land. I have tried setting userAgent and ‘user-agent’ as keys on capabilities: There is this answer which says to use a firefox profile, but that’s not exposed. There is no driver.FirefoxProfile nor one exposed globally nor webdriver.FirefoxProfile nor …
How to Disable V8’s Optimizing Compiler
I’m writing a constant-time string comparison function (for node.js) and would like to disable V8’s optimizing compiler for this single function; using command-line flags are out of the question. I know that using a with{} (or try/catch) block will disable the optimizing compiler now, but I’…
DWG converter for Node.js or Javascript library
I want to show AutoCAD-files (.DWG) in my AngularJS application and I’m using a Node.js backend for my application. Are there any DWG libraries in Javascript? Are there any DWG Node libraries to convert DWG files to a SVG / PDF / … I don’t want to edit them; just show them online in my appli…
What happens if i reject / resolve multiple times in Kriskowal’s q?
I’m studying the promises pattern and using kriskowal’s q for node.js, having this snippet: What if both the parser fails and some_reason is true? Will the execution procede from rejecting through resolving and both promise’s method be called at different times, thus generating a bug? Should…
How to chain exceptions in javascript (ie add cause like in java)
Is there a standard / best practice way to add a cause of an exception in javascript. In java you might do this: When the resulting exception is printed, it’ll give you a nice trace that includes causes. Is there any good way to do this in javascript or do I have to roll my own? Answer In prod, we