Build a query string from an object of data.
The data to turn into a query string.
The query string.
const data = { param1: 'value1', param2: 'value2' };// returns 'param1=value1¶m2=value2'const queryString = buildQuery(data); Copy
const data = { param1: 'value1', param2: 'value2' };// returns 'param1=value1¶m2=value2'const queryString = buildQuery(data);
Use new URLSearchParams(data).toString(). It encodes spaces as + rather than %20 and also escapes '()!, which decode to the same values. Will be removed in goldies 6.0.
new URLSearchParams(data).toString()
+
%20
'()!
Build a query string from an object of data.