Skip to content

Commit

Permalink
samples: added default value for undefined (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
galz10 authored and Ace Nassri committed Nov 14, 2022
1 parent 7974be0 commit 596c5c4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion document-ai/process-document-specialized.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 596c5c4

Please sign in to comment.