Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

$http doesn't support nested params for GET #2091

Closed
jr314159 opened this issue Mar 1, 2013 · 1 comment
Closed

$http doesn't support nested params for GET #2091

jr314159 opened this issue Mar 1, 2013 · 1 comment

Comments

@jr314159
Copy link

jr314159 commented Mar 1, 2013

We have an API that expects nested parameters. We'd previously been communicating with this API fine using $.ajax (which uses $.param), but Angular's $http uses a buildUrl method that is not recursive so it doesn't work with nested objects.

Two possible solutions for us right now are to use POST instead, or to manually construct a flat object with name value pairs first using $.param and then pass that into $http like so:

        obj = {}
        _.map $.param(params).replace(/\+/g, "%20").split("&"), (pair) ->
          [name, value] = _.map(pair.split("="), (i) -> decodeURIComponent(i))
          obj[name] = value
        obj

This is obviously not ideal. Is it possible to get Angular to use a more jQuery-like param serializing method for GET requests?

@pkozlowski-opensource
Copy link
Member

Let's move discussion about serialization of query params to #3740, which is about the same issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants