I am conducting an exercise using nodejs in the REPL, I have been given a URL and am required to use querystring.parse() on it after accessing it via process.argv[] to retrieve the value of a and b and log them to the console. This is the string:
"http://127.0.0.1:8080/test?a=100&b=200"
Here is my code so far
const qs = require("querystring");
function fn() {
var query = qs.parse(process.argv[2]);
console.log("query a is " + query["a"]);
console.log("query b is " + query["b"]);
}
module.exports.fn = fn();
The exercise requires the final two console logs to return as follows:
'query a is 100'
'query b is 200'
But the output I am getting is:
query a is undefined
query b is 200
and when I return the query object itself I get this:
{ 'http://127.0.0.1:8080/test?a': '100', b: '200' }