Created
June 28, 2019 14:03
-
-
Save rajaramtt/fef7190ca9b5f5505f77fd0a1a6f362d to your computer and use it in GitHub Desktop.
object into query string parameters in JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var params = { | |
a: 1, | |
b: 2, | |
c: 3 | |
}; | |
var queryString = Object.keys(params).map(key => key + '=' + params[key]).join('&'); | |
// or | |
var queryString = Object.keys(params).map(function(key) { | |
return key + '=' + params[key] | |
}).join('&'); | |
// jquery | |
var queryString = $.param(params); | |
// node.js module | |
const querystring = require('querystring'); | |
let queryString = querystring.stringify(params); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment