-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsimple.vue
34 lines (29 loc) · 938 Bytes
/
simple.vue
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
<template>
<button :disabled="!ready" @click="open">
Connect a bank account
</button>
</template>
<script lang="ts" setup>
import { computed } from 'vue';
import { useFetch } from '@vueuse/core';
import type { PlaidLinkOnSuccess, PlaidLinkOptions } from '@jcss/vue-plaid-link';
import { usePlaidLink } from '@jcss/vue-plaid-link';
const { data } = useFetch<{ link_token: string }>('/api/create_link_token', { method: 'POST' });
const token = computed(() => {
if (!data.value) { return ''; }
return data.value.link_token;
});
const onSuccess: PlaidLinkOnSuccess = (publicToken, metadata) => {
// send public_token to your server
// https://plaid.com/docs/api/tokens/#token-exchange-flow
console.log(publicToken, metadata);
};
const config = computed(() => {
const config: PlaidLinkOptions = {
token: token.value,
onSuccess,
};
return config;
});
const { open, ready } = usePlaidLink(config);
</script>