With node.js
Code:
var querystring = require('querystring');
...
console.log("Incoming: ", event);
var output = querystring.parse(event);
console.log("Key 1 value is: ", output.key1);
Output:
Incoming: { key3: 'value 3', key2: 'value 2', key1: 'value 3' }
Key 1 value is: undefined
Why is the Key1 value printed as undefined (although incoming event is printed correctly just before that)?
Your event
object isn't a querystring, so there isn't anything to parse in this case.
querystring
is for parsing raw HTTP query strings:
var qs = require('querystring');
var parsed = qs.parse("key1=value3&key2=value2&key3=value1");
// { key1: 'value3', key2: 'value2', key3: 'value1' }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.