Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

urlsearchparams array

function buildParams(data) {
    const params = new URLSearchParams()

    Object.entries(data).forEach(([key, value]) => {
        if (Array.isArray(value)) {
            value.forEach(value => params.append(key, value.toString()))
        } else {
            params.append(key, value.toString())
        }
    });

    return params.toString()
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #urlsearchparams #array
ADD COMMENT
Topic
Name
6+8 =