i have an array of strings like below
const array = ["string1", "string2", "string3"];
const total = 10000;
and i have a url that has string interpolation like below
const url = `http://localhost:8080/total=${total}&array=${array}`
which gives me back the below
http://localhost:8080/total=10000&array=[string1, string2, string3]
How can i make the array of strings to work with the string interpolation with JS.
expected result should be something like
http://localhost:8080/total=10000&array=["string1", "string2", "string3"]
Any help is appreciated
["string1", "string2", "string3"]in your URL? This is a very uncommon kind of value to have in a URL.JSON.stringifyis the way to go, as Ori Drori said.