From 8c890d224afffb473ffcf85c45952dbaec82570c Mon Sep 17 00:00:00 2001
From: diazjj <jjdiaz@cttc.es>
Date: Thu, 25 Jul 2024 16:38:07 +0200
Subject: [PATCH] Return empty value if there are no records match a key

---
 src/dlt/gateway/dltApp/src/dltGateway.js | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/dlt/gateway/dltApp/src/dltGateway.js b/src/dlt/gateway/dltApp/src/dltGateway.js
index 7ee723e7c..80eeebc17 100644
--- a/src/dlt/gateway/dltApp/src/dltGateway.js
+++ b/src/dlt/gateway/dltApp/src/dltGateway.js
@@ -101,7 +101,8 @@ async function getFromDlt(call, callback) {
 
     // Send the response with the formatted JSON data
     callback(null, { record_id: call.request, data_json: JSON.stringify(result) });
-  } catch (error) {    if (error.message.includes("data not found for key")) {
+  } catch (error) {   
+   if (error.message.includes("data not found for key")) {
     // Return an empty response when no record is found
     callback(null, { record_id: call.request, data_json: "{}" });
   } else {
@@ -110,6 +111,7 @@ async function getFromDlt(call, callback) {
       code: grpc.status.UNKNOWN,
       details: error.message
     });
+   }
   }
 }
 
-- 
GitLab