From cf04fffdad6ecbdfe5b0ed13529fb414632b9087 Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Mon, 13 Mar 2023 16:22:55 +0000 Subject: [PATCH] Fix API Error handling --- .../TestConfiguration/InternalAPIClient.ts | 7 +++---- .../TestConfiguration/accountsAPIClient.ts | 10 ++++------ .../public-api/TestConfiguration/PublicAPIClient.ts | 8 ++++---- .../public-api/TestConfiguration/accountsAPIClient.ts | 7 ++++--- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/qa-core/src/config/internal-api/TestConfiguration/InternalAPIClient.ts b/qa-core/src/config/internal-api/TestConfiguration/InternalAPIClient.ts index 2dc0487095..1c79f47609 100644 --- a/qa-core/src/config/internal-api/TestConfiguration/InternalAPIClient.ts +++ b/qa-core/src/config/internal-api/TestConfiguration/InternalAPIClient.ts @@ -55,11 +55,10 @@ class InternalAPIClient { response.status == 403 ) { console.error("Error in apiCall") - console.error("Response:") - console.error(response) + console.error("Response:", response) const json = await response.json() - console.error("Response body:") - console.error(json) + console.error("Response body:", json) + console.error("Request body:", requestOptions.body) } return response } diff --git a/qa-core/src/config/internal-api/TestConfiguration/accountsAPIClient.ts b/qa-core/src/config/internal-api/TestConfiguration/accountsAPIClient.ts index aff821a7ac..9de03b75b6 100644 --- a/qa-core/src/config/internal-api/TestConfiguration/accountsAPIClient.ts +++ b/qa-core/src/config/internal-api/TestConfiguration/accountsAPIClient.ts @@ -44,12 +44,10 @@ class AccountsAPIClient { const response = await fetch(`${this.host}${url}`, requestOptions) if (response.status == 404 || response.status == 500) { console.error("Error in apiCall") - console.error("Response:") - console.error(response) - console.error("Response body:") - console.error(response.body) - console.error("Request body:") - console.error(requestOptions.body) + console.error("Response:", response) + const json = await response.json() + console.error("Response body:", json) + console.error("Request body:", requestOptions.body) } return response } diff --git a/qa-core/src/config/public-api/TestConfiguration/PublicAPIClient.ts b/qa-core/src/config/public-api/TestConfiguration/PublicAPIClient.ts index d9f4aa4816..657ca22ff8 100644 --- a/qa-core/src/config/public-api/TestConfiguration/PublicAPIClient.ts +++ b/qa-core/src/config/public-api/TestConfiguration/PublicAPIClient.ts @@ -65,10 +65,10 @@ class PublicAPIClient { response.status == 403 ) { console.error("Error in apiCall") - console.error("Response:") - console.error(response) - console.error("Response body:") - console.error(response.body) + console.error("Response:", response) + const json = await response.json() + console.error("Response body:", json) + console.error("Request body:", requestOptions.body) } return response } diff --git a/qa-core/src/config/public-api/TestConfiguration/accountsAPIClient.ts b/qa-core/src/config/public-api/TestConfiguration/accountsAPIClient.ts index 44b69aa247..2ea465adda 100644 --- a/qa-core/src/config/public-api/TestConfiguration/accountsAPIClient.ts +++ b/qa-core/src/config/public-api/TestConfiguration/accountsAPIClient.ts @@ -48,9 +48,10 @@ class AccountsAPIClient { response.status == 400 ) { console.error("Error in apiCall") - console.error(response) - console.error(response.body) - console.error(requestOptions.body) + console.error("Response:", response) + const json = await response.json() + console.error("Response body:", json) + console.error("Request body:", requestOptions.body) } return response }