Skip to content

Instantly share code, notes, and snippets.

@stemar
Last active March 21, 2025 02:52
Show Gist options
  • Save stemar/cd003e61d8e69fcf647b0662d9050b45 to your computer and use it in GitHub Desktop.
Save stemar/cd003e61d8e69fcf647b0662d9050b45 to your computer and use it in GitHub Desktop.
Create a http query string in ES6 JavaScript (no array in query string)
function http_query(data, arg_separator) {
var query = [];
for (var key in data) {
query.push(encodeURIComponent(key) + "=" + encodeURIComponent(data[key].toString()));
}
return array.join(arg_separator || "&");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment