From 596c5c41e06111d791f73e75ae841956326448a9 Mon Sep 17 00:00:00 2001 From: Gal Zahavi <38544478+galz10@users.noreply.github.com> Date: Tue, 14 Dec 2021 14:19:12 -0800 Subject: [PATCH] samples: added default value for undefined (#287) --- document-ai/process-document-specialized.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/document-ai/process-document-specialized.js b/document-ai/process-document-specialized.js index d8be171c1f..ceed144893 100644 --- a/document-ai/process-document-specialized.js +++ b/document-ai/process-document-specialized.js @@ -74,7 +74,8 @@ async function main(projectId, location, processorId, filePath) { const key = entity.type; // some other value formats in addition to text are availible // e.g. dates: `entity.normalizedValue.dateValue.year` - const textValue = entity.textAnchor.content; + const textValue = + entity.textAnchor !== null ? entity.textAnchor.content : ''; const conf = entity.confidence * 100; console.log( `* ${JSON.stringify(key)}: ${JSON.stringify(textValue)}(${conf.toFixed(