Skip to content

Superagent adds duplicative array syntax #89

Closed

Description

@kadamwhite

superagent is transforming the (already-formatted) type[]=type1&type[]=type2 portion of the URL into type[][0]=type1&type[][1]=type2. This results in the following error:

http://[test site url]/wp-json/posts?filter%5Bcity%5D=cityname&type%5B%5D=event&type%5B%5D=evttype
{ [Error: cannot GET /wp-json/posts?filter%5Bcity%5D=cityname&type%5B%5D[0]=event&type%5B%5D[1]=evttype (403)]
  status: 403,
  method: 'GET',
  path: '/wp-json/posts?filter%5Bcity%5D=cityname&type%5B%5D[0]=event&type%5B%5D[1]=evttype' }

This can be avoided by removing the [] around the type property, since superagent evidently inserts the array syntax and indices itself; effectively, the resolution here will be to eliminate the prepareParameters method from inside the wp-request module, as this behavior of superagent obviates our need to write the syntax ourselves.

I speculated in #84 (whence this issue) that we should consider tossing Superagent in favor of a request library with unexpected behavior; upon reflection, Superagent is doing an OK job and we'd be making undue extra work were we to switch. This bug will be fixed in isolation.

Activity

  1. added a commit that references this issue on Dec 3, 2014
    44458b4
  2. modified the milestone: 0.3.1 on Dec 3, 2014
  3. added 3 commits that reference this issue on Dec 4, 2014
    862780a
    87268b7
    b3b0615
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions