-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
[10.x] Add withQueryParameters
to the HTTP client
#47297
Conversation
withQueryParameters
to the HTTP clientwithQueryParameters
to the HTTP client
Http::convertKit()->get('users', ['search' => 'Matthieu']); Will this code overwrite the query specified in the macro? |
Some APIs require some query parameters to be always set. For example auth token (even though this isn't a great practice). With this new helper, we can create a macro with the query parameter always set.
e878d16
to
82ff63d
Compare
@cosmastech good question, only one way to find out. I added a new test to the PR, the query parameters are merged together 👍 |
@mnapoli what about some tests to confirm behavior around arrays? For example: $this->factory->withQuery(
['foo' => ['bar', 'baz']],
)->get('https://laravel.com'); And other related scenarios. Can you mark as ready for review again when that is done? Thanks! |
@mnapoli are you still working on this? |
@driesvints apologies for the delay, I added more tests to cover these behaviors:
This is the behavior I would expect and I think makes sense, let me know if you think otherwise. |
* Add `withQueryParameters` to the HTTP client Some APIs require some query parameters to be always set. For example auth token (even though this isn't a great practice). With this new helper, we can create a macro with the query parameter always set. * Add more tests for `withQueryParameters` with arrays See laravel/framework#47297 (comment) * formatting --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
Some APIs require some query parameters to be always set. For example auth token (even though this isn't a great practice).
With this new helper, we can create a macro with the query parameter always set.
Example:
can become: