node.jsRelated issues-Collection of common programming errors
Ben
javascript json node.js object asynchronous
I am new to Node and struggling to access a simple JSON object. My request.body will have JSON content similar to the following:{“store_config”: [{“name”: “hello”,”name2″: “world”}] }The “store_config” value will always be present, however the keys and values within could be anything.How can I iterate through the keys and values to access each? I would also like to process each in an asynchronous manner.Appreciate any thoughts or direction.UPDATEconsole.log(typeof(request.body));Returns: Objectp
erythraios
javascript ajax node.js
I have an object containing a date object. When I post it to a NodeJS server, it’s still an object but the time has been converted to a string. Is there any way to avoid this? I can’t parse the entire object because I get an “Unexpected token o” error (I assume because it’s still an object). Before:Object {title: ” – fd”, start: Tue Feb 11 2014 09:00:00 GMT-0500 (EST), end: Tue Feb 11 2014 10:00:00 GMT-0500 (EST), allDay: false, id: “”.}After: Object allDay: “false” end: “Tue Feb 11 2014 10:00:0
Faran
node.js global-variables user-agent sails.js controllers
I am trying to have a variable which can be accessible by all controllers in my node project. Currently in one controller I have:var ua = req.headers[‘user-agent’];var isMobile = “no”;if(/mobile/i.test(ua))isMobile=”yes”;It’s pointless to copy past all of this for all my controllers and pass the isMobile variable to the view. I’d like to get the value of isMobile set once, and then pass it wherever I want from my controllers.Is there an easy way to do this rather than have those 4 lines of code
Kevin Bradshaw
node.js ubuntu-12.04
I have just installed node.js on my ubuntu laptop.I followed the instructions found here: http://davidtsadler.com/archives/2012/05/06/installing-node-js-on-ubuntu/#application and installed from the git repositoryInstalled with no errors, but when I ran the server.js sample application program nothing happened. Worse still, I tried to run a ver basic hello world script called hello.jsconsole.log(“hello world”);When I type : node hello.jsnothing happens, there is no error message, nothing is writ
Tarion
node.js angularjs express jade mixins
Related to that question: Jade Mixins in AngularJSI have the following (simplified) code:tr(ng-repeat=”avatar in avatars”)+avatarRow({name: ‘{{avatar.name}}’})mixin avatarRow(avatar)td avatar.nameSince it is a bit dirty to resolve the “avatar” object before it is passed to the mixin I would prefer a more angular like solution.Still it would be cool, to keep the mixin code in the same file, but thats not a must. As far as I see, with ngInclude I can no pass any args. So how to handle that?Continu
gelly
node.js angularjs socket.io localhost
I’m using an AngularJs, node & socket.io to write an app where I want to have some shared data in my different clients. I’m looking at this example: https://github.com/mhevery/angular-node-socketioI get everything up and running and it works fine if I go to the location of my index.html in my file system (c:/user/angularnodesocket/index.html), but when I go to localhost:8888 the site still shows but the angular stuff is not interpretated.I get this error on localhostResource interpreted as S
Ali
javascript jquery node.js
I’m getting Uncaught SyntaxError: Unexpected token ILLEGAL And I checked that because of thiscurrentMd: ‘<div>#hehe</div>’The two extra new line that is in the currentMd breaking it, so how can I instead replacing that new lines with \n ??So it will be like this insteadcurrentMd: ‘<div>#hehe\n\n</div>’In javascript or jQuery would be fine.It may be not clear that the content is actually just an example here.The actual content is being retrieved from a database, so in the
fancy
javascript json node.js npm
What could be wrong here?/opt/local/lib/node/.npm/embedly/0.3.2/package/package.json:1 “name”: “embedly^node.js:134throw e; // process.nextTick error, or ‘error’ event on first tick^ 13 Apr 02:23:06 – [ERROR] SyntaxError SyntaxError: Unexpected token :package.json{ “name”: “embedly” , “version”: “0.3.2” , “description”: “Embedly client library for node” , “homepage”: “https://github.com/embedly/embedly-node” , “keywords”: [] , “author”:{ “name”: “Bob Corsaro”, “email”: “[email protected]”, “url”: “ht
Jorge Aranda
node.js express jade
I have a Jade template with lines like these:htmlheadtitle Person Detailsscriptvar Person = function () {this.name = “#{person.name}”,this.contactInfo = “#{person.contactInfo}”} …When I render this template I pass it a person object.The problem is that some of the fields I pass to the template (such as person.contactInfo above) may have newline characters, and the rendering process outputs something like this:<html><head><title>Person Details</title><script>var Pe
opcode
mysql database node.js scaling multi-master-replication
I am creating this web application in Node.js and MySQL and I am struggling on data synchronisation. Here’s the scenario:Suppose we have 1000 customers that all have a local webserver-database in their office/site. A user can login, edit data, datalog sensors, etc. All these activities contribute to, for the sake of the example, around 500KB of table data per day, per customer/site. So each of the 1000 customers have a local database that will always constantly get updated with new data many tim
Web site is in building