Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
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

Description

@jr314159

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions