-
Notifications
You must be signed in to change notification settings - Fork 9
Inject Requests With Query Parameter Object? #334
Comments
Could be a nice feature. However, as hapi only supports the standard node querystring module out of the box, we'd have to do the internal stringifying with that. It could lead to some confusing behaviours for people thinking they could pass complex nested objects in. I suppose though we could validate that the object is a simple flat dictionary of key value-pairs. |
@mtharrison if people are putting in complex objects they are probably already using |
How do you mean by:
How would that look exactly? |
@mtharrison Ok I thought you could pass qs to hapi to let it use that but I must have read it wrong, this is how you should do it aperently hapijs/hapi#2985 In that case using the default seems fine, if they use the fix from the issue referenced above it will work right? |
Yes, but that's all about how to parse the qs-encoded string from a URL into an object so it's available in We don't want to use qs internally because we've already dropped that - so the only alternative I see is to use Node's built-in querystring module and limit to simple objects. If someone wants to use the qs format, it's then up to them to build the URL for themselves instead. |
@mtharrison derp you're right 🙃 |
I agree with your points @mtharrison I took a look through how query strings are handled in relation to Personally, I'm fine with using simple objects for the query string for my particular use case. |
For testing we want to go through and be able to use an object for our query parameters when executing
server.inject(...)
but I'm not seeing a method to be able to do just that. I realize that we would be able to accomplish this through a method such as the following:But it would be preferable to avoid that boilerplate and just be able to send a straight object. Something like the following:
The text was updated successfully, but these errors were encountered: