Skip to content

Commit aeade60

Browse files
[9.x] Add remaining response helpers (#8526)
* [9.x] Add remaining response helpers and sort them * fix function params * Update http-client.md * Update http-client.md * formatting * Update http-client.md --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 7a3dfda commit aeade60

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

http-client.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,13 @@ To make requests, you may use the `head`, `get`, `post`, `put`, `patch`, and `de
4141
The `get` method returns an instance of `Illuminate\Http\Client\Response`, which provides a variety of methods that may be used to inspect the response:
4242

4343
$response->body() : string;
44-
$response->json($key = null) : array|mixed;
44+
$response->json($key = null, $default = null) : array|mixed;
4545
$response->object() : object;
4646
$response->collect($key = null) : Illuminate\Support\Collection;
4747
$response->status() : int;
48-
$response->ok() : bool;
4948
$response->successful() : bool;
5049
$response->redirect(): bool;
5150
$response->failed() : bool;
52-
$response->notFound() : bool;
53-
$response->serverError() : bool;
5451
$response->clientError() : bool;
5552
$response->header($header) : string;
5653
$response->headers() : array;
@@ -59,6 +56,25 @@ The `Illuminate\Http\Client\Response` object also implements the PHP `ArrayAcces
5956

6057
return Http::get('http://example.com/users/1')['name'];
6158

59+
In addition to the response methods listed above, the following methods may be used to determine if the response has a given status code:
60+
61+
$response->ok() : bool; // 200 OK
62+
$response->created() : bool; // 201 Created
63+
$response->accepted() : bool; // 202 Accepted
64+
$response->noContent() : bool; // 204 No Content
65+
$response->movedPermanently() : bool; // 301 Moved Permanently
66+
$response->found() : bool; // 302 Found
67+
$response->badRequest() : bool; // 400 Bad Request
68+
$response->unauthorized() : bool; // 401 Unauthorized
69+
$response->paymentRequired() : bool; // 402 Payment Required
70+
$response->forbidden() : bool; // 403 Forbidden
71+
$response->notFound() : bool; // 404 Not Found
72+
$response->requestTimeout() : bool; // 408 Request Timeout
73+
$response->conflict() : bool; // 409 Conflict
74+
$response->unprocessableEntity() : bool; // 422 Unprocessable Entity
75+
$response->tooManyRequests() : bool; // 429 Too Many Requests
76+
$response->serverError() : bool; // 500 Internal Server Error
77+
6278
<a name="uri-templates"></a>
6379
#### URI Templates
6480

0 commit comments

Comments
 (0)