2

My macro is called from a url containing parameters like:

?title=TitleHere&macro.id=a1

I'm finding it easy to pick up the title, but I am getting an error when trying to get the macro.id parameter as follows.

var requestTitle = req.query.title;
var requestMacroId = req.query.macro.id;

What is the correct way to get a parameter with a period in the name?

alexmac
  • 19,087
  • 7
  • 58
  • 69
Thomas
  • 375
  • 2
  • 10
  • Possible duplicate of [How to get JSON objects value if its name contains dots?](https://stackoverflow.com/questions/2577172/how-to-get-json-objects-value-if-its-name-contains-dots) – str Aug 23 '17 at 11:17
  • @str it's about express node.js module, not about parsing json. – alexmac Aug 23 '17 at 11:18
  • 3
    @Thomas try `req.query['macro.id']`. – alexmac Aug 23 '17 at 11:19
  • @alexmac It is not specific to the module, but to how you access properties. The same concepts apply. – str Aug 23 '17 at 11:19
  • The context is different enough that I wouldn't have known that question had the same answer. Thanks to @alexmac and kGielo, it's solved. – Thomas Aug 23 '17 at 13:24

1 Answers1

4

Try

var requestTitle = req.query['title'];
var requestMacroId = req.query['macro.id'];
kGielo
  • 371
  • 1
  • 9