Created
January 20, 2022 17:54
-
-
Save hoyangtsai/2323e7932d295b53b023cdbb781cc27e to your computer and use it in GitHub Desktop.
object to url query string #snippet
This file contains 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
// convert objec to a query string | |
const qs = Object.keys(params) | |
.map(key => `${key}=${params[key]}`) | |
.join('&'); | |
// OR | |
var queryString = Object.keys(params).map((key) => { | |
return encodeURIComponent(key) + '=' + encodeURIComponent(params[key]) | |
}).join('&'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment