-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
45 lines (33 loc) · 887 Bytes
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCHTML html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdn.plaid.com/link/v2/stable/link-initialize.js"></script>
<title> Plaid demo app</title>
</head>
<body>
<button id="link-button">Link account</button>
<script>
async function createPlaid() {
const linkToken = await $.get('/create-link-token');
console.log(linkToken);
const handler = Plaid.create({
token: linkToken,
onSuccess: function (publicToken, metadata) {
fetch('/exchange-token', {
method: 'POST',
body: JSON.stringify({ publicToken}),
headers: {
'Content-Type': 'application/json',
}
});
}
})
$("#link-button").on("click", function (e) {
handler.open();
})
}
createPlaid();
</script>
</body>
</html>