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 12, 2022
1 parent 8bbb2d2 commit 00fb03d
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 00fb03d

Please sign in to comment.