I am using MongoDB + Node.js to create an app, but I am receiving an error for this code: company.js api.js Error friends.name: req.body.friendName, SyntaxError: Unexpected token . I also tried with friend[‘name’] but the result was the same: SyntaxError: Unexpected token [ Please tell me where is…
Tag: node.js
parseInt() parses number literals with exponent incorrectly
I have just observed that the parseInt function doesn’t take care about the decimals in case of integers (numbers containing the e character). Let’s take an example: -3.67394039744206e-15 I expected that the parseInt will also return 0. What’s going on at lower level? Why does parseInt retur…
Communicate with the serial port from client web browser.
In my web application(sencha extjs 5) I have a user requirement to read/write data to the client PC serial port. I am aware of the client browser can not access local machine hardware without installing some binaries on the local machine(Native app, Windows Service, etc..). I have seen the same question is di…
Which is the prefered way to add function to sockets in socket.io?
Is there a “prototype” of all sockets connected to socket.io? I want to define some functions that will be available for each connected socket. Currently i have: But i’m defining a ‘new’ hello function for each socket. Is there a socket prototype? so i can have something like: An…
Sequelize Where statement with date
I am using Sequelize as my backend ORM. Now I wish to do some WHERE operations on a Date. More specifically, I want to get all data where a date is between now and 7 days ago. The problem is that the documentation does not specify which operations you can do on Datatypes.DATE Can anyone point me in the right
Calling JavaScript from C++ with node.js
Is there a way to call JS functions from C++ through node.js (as callbacks or something like that)? If yes, how? I’m searching for it on the web, but haven’t found any helpful resource. Thanks in advance Answer One way to do it form a native addon can be using the provided function as a callback, …
AWS S3 JavaScript SDK getSignedUrl returns base path only
I have some very simple code for generating an S3 URL. The URL I get back from the SDK only has the base path for S3. It doesn’t contain anything else. Why is this happening? Node.js v0.12.0, AWS SDK 2.1.15 or 2.1.17, Windows 7 64-bit, Answer The problem wasn’t with code. It turns out that when yo…
ReadFile in Base64 Nodejs
I’m trying to read an image from client side encoded in base64. How to read with nodejs? My code: But, I got this error: Answer Latest and greatest way to do this: Node supports file and buffer operations with the base64 encoding: Or using the new promises API:
Client Socket.io disconnects and reconnects to websocket persistently
I am connected via Socket.io 1.3.4 (via websockets) to the NodeJS server and client socket.io fires up “disconnect” event 5-30 seconds. Every “disconnect”->”reconnecting”->”reconnect” iteration takes approx. 2 seconds. I am connected via cable to pretty st…
Mongoose JS findOne always returns null
I’ve been fighting with trying to get Mongoose to return data from my local MongoDB instance; I can run the same command in the MongoDB shell and I get results back. I have found a post on stackoverflow that talks about the exact problem I’m having here; I’ve followed the answers on this pos…