I would like to pass an array and added to a link on my page as a URL parameter, because later on the server side I need the values from the array. How should I do that?
Pass an array of strings as URL parameters:
const myLink = 'https:/example.com/api' const myArray = ['aaa', 'bbb', 'ccc']; let apiUrl = `${myLink}/query?`; myArray.forEach((x) => { apiUrl += `&array=${x}`; }); console.log(apiUrl); // https://example.com/api/query?array="aaa"&array="bbb"&array="ccc"