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

Request/Suggestion - path parameters vs query parameters #44

Closed
dboune opened this issue Nov 27, 2017 · 2 comments
Closed

Request/Suggestion - path parameters vs query parameters #44

dboune opened this issue Nov 27, 2017 · 2 comments
Assignees
Milestone

Comments

@dboune
Copy link
Contributor

dboune commented Nov 27, 2017

I believe it would be helpful if there were either a way to filter the params prior to passing them to axios but after using them in the path without using paramsSerializer, or if they were just considered two separate things entirely. I would prefer the latter.

Unless I've missed something, without importing a serializer like qs and using it in paramsSerializer it does not seem possible to strip params that have been used in the path.

The following results in a URL like:
/projects/{projectId}/participants?projectId={projectId}&active=1

.get({
  action: 'getProjectParticipants',
  property: 'participants',
  queryParams: true,
  path: { projectId } => `/projects/${projectId}/participants`
})
getProjectParticipants({
  params: {
    projectId: '123',
    active: '1'
  }
})

Something like the following would feel more intuitive to me. (I'm not intending to suggest key names)

.get({
  action: 'getProjectParticipants',
  property: 'participants',
  path: { projectId } => `/projects/${projectId}/participants`
})
getProjectParticipants({
  path: {
    projectId: '123',
  },
  query: {
    active: '1'
  }
})
@christianmalek
Copy link
Owner

Hello Damian,

Thank you for your request. The decision of passing query parameters to the request URL or appending the data to the body is made during the Resource creation. So at the moment it's not possible to react on your suggested query property to only use query parameters when this field is set.

It could be possible to apply your suggestion, e.g. by wrapping the Resource.requestFn in an additional function. But I don't going to implement this in v2 anymore. I'm sorry. I'll remember it for v3.

@christianmalek
Copy link
Owner

I've added it to #57 and will close this issue. Feel free to open a new one.

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

No branches or pull requests

2 participants