I am receiving a json response to construct a parameterized string in JavaScript. However I need to pass actual parameters from JavaScript on some properties eg custom_input
has to change dynamically.
[{ "road_name_gr": "custom_input" "town_code": 1 }]
Then I read that json file and convert that to a url.
cql_filter = new URLSearchParams(json_file).toString();
output: town_code=1&road_name_gr=custom_input
However I have to "modify" the url to accept input.
eg 'town_code=1&road_name_gr=' + my_custom_input
Try this:
my_custom_input = decodeURIComponent(my_custom_input) // URI Decode
let input_params = new URLSearchParams(json_file);
input_params.set("road_name_gr", my_custom_input);
cql_filter = input_params.toString();
You have to set parameter before obtain string value.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.