GET variable name contains dash creates problems for req.query for NodeJS Express?
express, javascript, node.js
Solution
In javascript, object values can be accessed by using either `.` or `[]` When the key contains a dash, you cannot use the `.` notation because the `-` will be interpreted as "minus". This is not related to `express`, it's just how javascript works.
So you should use:
req.query["message-timestamp"]
Problem
I'm making a GET endpoint that handles this variable in Node.js using Express: ``` ?message-timestamp=2012-08-19+20%3A38%3A23 ``` I'm having trouble accessing it using req.query. Accessing req.query.message-timestamp throws an error ("ReferenceError: timestamp is not defined"). Clearly the dash isn't playing nice. Any obvious way around that?