I'm having trouble finding guidance on the best-practice way to do this with angular (2+). Angular's HttpClient's post function has an HttpParams parameter. HttpParams is a key/value map of type [param: string]: string | string[]
. But, I need to post a multidimensional array (2D) parameter (string[][]
). i.e.
this.http.post(url, {}, {
params: {
2d: [ [ 'arr1' ], [ 'arr2' ] ]
}
});
But this does not seem to be supported by angular's HttpParams class. While searching around other questions, I found out that
this is possible in angularJS using the same
Content-Type
that angular uses (application/x-www-form-urlencoded
).this is possible without a framework in vanilla js, but you must encode your multidimensional array on the client side
I'm wondering if there is a clean way to do this in angular. If there is not, why did angular make this design decision and what is a workaround?