Skip to content

Commit 596c5c4

Browse files
galdawaveAce Nassri
authored andcommitted
samples: added default value for undefined (#287)
1 parent 7974be0 commit 596c5c4

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

document-ai/process-document-specialized.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ async function main(projectId, location, processorId, filePath) {
7474
const key = entity.type;
7575
// some other value formats in addition to text are availible
7676
// e.g. dates: `entity.normalizedValue.dateValue.year`
77-
const textValue = entity.textAnchor.content;
77+
const textValue =
78+
entity.textAnchor !== null ? entity.textAnchor.content : '';
7879
const conf = entity.confidence * 100;
7980
console.log(
8081
`* ${JSON.stringify(key)}: ${JSON.stringify(textValue)}(${conf.toFixed(

0 commit comments

Comments
 (0)