Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for nested params #135

Closed
wants to merge 2 commits into from
Closed

Conversation

smmr0
Copy link

@smmr0 smmr0 commented Aug 8, 2018

Allows passing nested parameters, e.g. a[b][c]=123

See also: kevinsawicki/http-request#147

@silkimen
Copy link
Owner

There is no standard (RFC spec) defining how to serialize deeply structured objects and arrays to be used for query strings.

// this data:
cons data = {
  a: 1,
  b: 2,
  c: [ 3, 4 ]
};

// can be serialized as:
const option1 = '?data[a]=1&data[b]=2&data[c][0]=3&data[c][1]=4';

// it could also be:
const option2 = '?data[a]=1&data[b]=2&data[c][]=3&data[c][]=4';

// or another one:
const option3 = '?data[a]=1&data[b]=2&data[c]=3&data[c]=4';

// or:
const option4 = '?data.a=1&data.b=2&data.c=3&data.c=4';

// or even:
const option5 = '?data[a]=1&data[b]=2&data[c.0]=3&data[c.1]=4';

It depends on the backend implementation and therefore I prefer to let the application developer do this part. It's up to you to serialize the query parameters before sending the request.

@silkimen silkimen closed this Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants