Parse Query String - Node.js String

Node.js examples for String:Parse

Description

Parse Query String

Demo Code


Util.parseQueryString = function(queryString) {
  var params = {};
  var queries = queryString.split("&");
  for (var i = 0; i < queries.length; i++ ) {
    var temp = queries[i].split('=');
    if (temp.length === 1) {
      params[temp[0]] = '';
    } else {//from   w  ww  . j  a v  a 2s.com
      params[temp[0]] = temp[1];
    }
  }
  return params;
};

Related Tutorials