-
Notifications
You must be signed in to change notification settings - Fork 21
feature: Support for query parameters #5
Comments
Nope. This doesn’t work because hapi, the underlying server framework, handles path parameters different to query parameters. They are not part of the route. We never needed different responses based on query params. So they aren’t configurable for the fake backend for now. The fake backend is pretty stupid and we don’t care if different query params deliver the same response. Must say that I’m not sure about adding support for them. I would add support if
Just in caseRegarding your example I could imagine to configure the query params like that: module.exports = SetupEndpoint({
name: 'v1',
urls: [{
params: '/read',
requests: [{
method: 'GET',
response: '/json-templates/anotherExample.json',
query: {
cmd: 'on-enter',
pid: '1414-414-567-3636'
}
}]
}]
}); I’m not sure about the expected behavior. Should it be analogous to the behavior of path params? That means:
More flexibilitySo I guess query params should have the same flexibility like path parameters: module.exports = SetupEndpoint({
name: 'v1',
urls: [{
params: '/read',
requests: [{
method: 'GET',
response: '/json-templates/anotherExample.json',
query: {
cmd: '{cmd}',
pid: '{pid?}'
}
}]
}]
}); That means: |
Hey mischah! We need support for query parameters! 🙂 Many thanks in Advance, |
Hi Mischah, I am using your project to mock backend and focus on my frontend work. Can you please implement query parameters in the urls if you get some time? Thank you, |
Hej @noobg1 @anujshankar @boochamoocha, challenge accepted. I just pushed a refactoring to master which hopefully improves maintainability and is a good start for adding this feature. Can’t promise anything right now because of a constraint I mentioned before: … but I’m going to tackle this within the next couple of days. Cheers, Michael |
Thanks @mischah! |
Hey Michael! We have our own implementation of handling query params for http-fake-server. Details of the implementation:
So basically if a user needs to handle query params then he/she just has to:
Example: Contents of mapURLs.js
Changes in the setup.js
Any suggestions to improve this approach? Thanks, |
Any news? I wasn't able to get the version of @anujshankar up and running... :-/ |
The only news is, that this one isn’t on the top of my priority list. Just because we still don’t need this feature. Therefore I wont make any promises about implementing it. But I'm open for a PR Sorry for the folks needing this 😕 Cheers, Michael |
Hi.
Thows error when url like this
The text was updated successfully, but these errors were encountered: