<button id="widget-button">Open Widget</button> <script src="https://link.deck.co/link-initialize.js"></script> <script type="text/javascript"> (async function() { // Create a new link_token to initialize widget const token = await fetch('/api/create_link_token', { method: 'POST', }).then(response => response.json()).then(data => data.link_token); const deck = Deck.create({ token, onSuccess({ job_guid }) { // Send the job_guid to your app server. fetch('/api/create_pending_connection', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ job_guid, // ...add your user metadata here }), }) }, onError({ reason }) { if (reason === 'InvalidCredentials') { // Handle invalid credentials } // Handle unexpected error }, onExit() { // The user exited the Widget flow. }, }); document.getElementById('widget-button').addEventListener('click', function() { deck.open(); }); })(); </script>
token
onSuccess({ job_guid })
onError({ reason })
onExit()
open()
deck.open();
exit()
deck.exit();
Was this page helpful?