From b6ab24acf56c99f06f85d385016c8a7137815407 Mon Sep 17 00:00:00 2001
From: Alexander Timmermann <alexander.timmermann@holi.social>
Date: Mon, 24 Mar 2025 14:07:55 +0100
Subject: [PATCH] debug: log full response of GeoAPI if not json

---
 app/adapters/geo/GeoApiClient.ts | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/app/adapters/geo/GeoApiClient.ts b/app/adapters/geo/GeoApiClient.ts
index 950166c..a55dd8b 100644
--- a/app/adapters/geo/GeoApiClient.ts
+++ b/app/adapters/geo/GeoApiClient.ts
@@ -49,13 +49,18 @@ export class GeoApiClient implements ResolvesCoordinates, ResolvesCity {
       'method': 'POST',
     })
 
-    const body = await response.json()
+    const body = await response.text()
+    try {
+      const data = JSON.parse(body)
+      if (Object.hasOwn(data, 'errors')) {
+        this.logger.error(data.errors)
+        throw new GraphQLError("Can't fetchPlaceDetails for geolocationId " + geolocationId)
+      }
 
-    if (Object.hasOwn(body, 'errors')) {
-      this.logger.error(body.errors)
-      throw new GraphQLError("Can't fetchPlaceDetails for geolocationId " + geolocationId)
+      return body as GeoAPIResponse
+    } catch (e) {
+      this.logger.error(`Response is not JSON: "${body}"`)
+      throw e
     }
-
-    return body as GeoAPIResponse
   }
 }
-- 
GitLab