Skip to content

Tag: node.js

socket.io – socket.on wait for promise

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…

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 …