[Vuejs]-JavaScript POST non-API request with repeated keys in payload

0👍

In my question above I am not true that I cannot use form submitting method. Of course, html form can have more fields with identical name= and if so, its submit generates a post request exactly as needed.

But while I create the form programmatically, I cannot fill it from dictionary, because dictionary cannot have repeated keys.

So I have modified the function proposed by Aquajet here pass post data with window.location.href and I check if params[key].constructor !== Array. I convert non-array values to array (with single element) and I cycle through such arrays. This allows me to have repeated values in the parameter (in such case I enter them as an array) and in the form.

So, this is answer to my problem. However it is a little strange to create lot of hidden inputs for such goal. So I am interested if there is a better way how to create the POST request.

Leave a comment