From 159c7a6d3c0f855e913de4ed576170cd4b436b1d Mon Sep 17 00:00:00 2001 From: raphj Date: Fri, 13 Jan 2023 14:14:34 +0100 Subject: [PATCH] docs: mention IResponse's getBody(), slash when catching Exception Signed-off-by: raphj --- developer_manual/digging_deeper/http_client.rst | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/developer_manual/digging_deeper/http_client.rst b/developer_manual/digging_deeper/http_client.rst index a34158415..d56624f46 100644 --- a/developer_manual/digging_deeper/http_client.rst +++ b/developer_manual/digging_deeper/http_client.rst @@ -24,6 +24,7 @@ HTTP client instances are built using the client service `factory clientService->newClient(); $response = $client->get('https://nextcloud.com'); + $body = $response->getBody(); } } @@ -36,6 +37,7 @@ HEAD request $client = $this->clientService->newClient(); $response = $client->head('https://nextcloud.com'); + $body = $response->getBody(); GET request @@ -47,6 +49,7 @@ GET request $client = $this->clientService->newClient(); $response = $client->get('https://nextcloud.com'); + $body = $response->getBody(); POST request ------------ @@ -68,7 +71,7 @@ POST request ], ]) ]); - $pizza = json_decode($response, true); + $pizza = json_decode($response->getBody(), true); PUT request ----------- @@ -90,7 +93,7 @@ PUT request ], ]) ]); - $pizza = json_decode($response, true); + $pizza = json_decode($response->getBody(), true); DELETE request -------------- @@ -129,6 +132,6 @@ Errors are signaled with exceptions. Catch PHP's base ``Exception``. $client = $this->clientService->newClient(); try { $response = $client->options('https://nextcloud.com'); - } catch (Exception $e) { + } catch (\Exception $e) { // Handle the error - } \ No newline at end of file + }