Last active
January 29, 2018 17:01
-
-
Save mkazlauskas/02bd1fbf8c0915736b643ae83ec174ed to your computer and use it in GitHub Desktop.
API example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function scanOnce() { | |
// Make sure running in Zamok and this specific API is available | |
var autofill = window.Zamok && window.Zamok.API && window.Zamok.API.Autofill; | |
if (!autofill) return Promise.reject("Either not in Zamok or 'zamok-api-autofill' solution is not enabled"); | |
// Enable and wait for a single scan. Returns parsed data. | |
return autofill.scan(); | |
} | |
scanOnce() | |
.then(data => console.log('Card scan successful', data)) // Do something with parsed data object | |
// Data should look like: | |
// {firstNameDL: "John", lastNameDL: "Smith", ...} | |
.catch(e => console.warn('Failed to scan card', e); // Handle scan failure (e.g. retry) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment