Skip to content

Commit bae5491

Browse files
authored
Add information about query strings
It was not obvious to me that you could use the second array argument with `Http::get()` for query parameters. I found it buried in a GitHub issue so I thought to add it to the docs.
1 parent 29c9fd6 commit bae5491

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

http-client.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,22 @@ The `Illuminate\Http\Client\Response` object also implements the PHP `ArrayAcces
5151
<a name="request-data"></a>
5252
### Request Data
5353

54-
Of course, it is common when using `POST`, `PUT`, and `PATCH` to send additional data with your request. So, these methods accept an array of data as their second argument. By default, data will be sent using the `application/json` content type:
54+
Of course, it is common when using `GET`, `POST`, `PUT`, and `PATCH` to send additional data with your request. So, these methods accept an array of data as their second argument. By default, data will be sent using the `application/json` content type:
5555

5656
$response = Http::post('http://test.com/users', [
5757
'name' => 'Steve',
5858
'role' => 'Network Administrator',
5959
]);
6060

61+
#### GET Requests Query Parameters
62+
63+
If you would like to send data using query parameters, you can either append the query string to the URL or pass an array of data to the second argument. When using the second argument with an array of data, this will automatically be parsed into the correct query string format, such as `http://test.com/users?page=1&query=Taylor`.
64+
65+
$response = Http::get('http://test.com/users', [
66+
'page' => 1,
67+
'query' => 'Taylor',
68+
]);
69+
6170
#### Sending Form URL Encoded Requests
6271

6372
If you would like to send data using the `application/x-www-form-urlencoded` content type, you should call the `asForm` method before making your request:

0 commit comments

Comments
 (0)