Skip to content
Advertisement

Tag: node.js

SyntaxError: Unexpected token

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 my mistake Answer Try: or: depend on what you’re after.

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 return 3 in this case (some snippets from the source code would be appreciated)?

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, for example let’s gonna

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 stable network. Server is hosted on AWS. Sometimes I have bad Wi-Fi connection, but no “disconnect” event fire up at all. How can I debug

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 post but I still can’t seem to

Advertisement