JS s'oppose à la question
const params = {foo:"Hi", bar:"there"}
const queryString = new URLSearchParams(params).toString();
console.log(queryString);
Obedient Octopus
const params = {foo:"Hi", bar:"there"}
const queryString = new URLSearchParams(params).toString();
console.log(queryString);
const params = {lat: 35.681236, lng: 139.767125, zoom: 15};
new URLSearchParams(params).toString();
// "lat=35.681236&lng=139.767125&zoom=15"
// OR
const queryString = Object.keys(params).map(key => {
encodeURIComponent(key) + '=' + encodeURIComponent(params[key])
}).join('&');
const queryString = Object.keys(params).map(key => {
encodeURIComponent(key) + '=' + encodeURIComponent(params[key])
}).join('&');
var queryString = Object.keys(params).map(key => key + '=' + params[key]).join('&');
const obj = {foo: "hi there", bar: "100%" };
const params = new URLSearchParams(obj).toString();
const queryString = new URLSearchParams(props.location.search);
//or
var queryString = Object.keys(params).map(key => key + '=' + params[key]).join('&');
//Extracting query String key value pairs
for (let param of queryString.entries()) {
console.log(param);
}