Handling Responses
The Web OCR SDK returns a Promise, which in case of success, will return an object with information about the collection of the selected document, or in case of error, will return a String with the error description. Below is an example of how to map each of these cases and get their results:
<script>
webOCR.initialize(document_type)
.then((ocr_key) => {
console.log(ocr_key)
})
.catch((error) => {
console.log(error)
})
</script>
Web OCR Return Description
| Attribute | Type | Description |
|---|---|---|
| ocr_info | Object | Success object containing information regarding the capture of the selected document. |
| error | String | String with the error description (if it occurs) |
Success Object Attributes
| Attribute | Type | Description |
|---|---|---|
| ocr_key | String | Identification key of the captured document images that can be used in any other QI Tech system service. |
| template | String | Type of captured document |
Error Types
| Error | Description |
|---|---|
| Invalid Web Token! Please verify your Web Token. | Web Token used is invalid. If you are certain that you are correctly using the Web Token provided by QI Tech, contact our support (suporte.caas@qitech.com.br) immediately. |
| Invalid Document Type! Please provide a valid document type. | Document Type passed to the WebOCR.initialize() function is not valid. Check the allowed document types on the initialize function page. |
| User left Web OCR. | The user returned from the Web OCR SDK before completing the document submission. |