When I call the Stripe.card.createToken
function in my api.js
file, I am trying to retrieve the generated token in order to utilize it within my Vuex. How can I achieve this?
// api.js
export const getStripeToken = async ({ cardInfo }) => {
const { data } = await Stripe.card.createToken({
cardInfo,
});
return data;
};
I am attempting to use the token in my Vuex actions like so. However, it seems to return undefined:
//vuex
import { getStripeToken } from '@src/store/api';
async fetchStripeToken({ dispatch }, { cardInfo }) {
const { data } = await getStripeToken({ cardInfo });
console.log('tokenId: ', data.tokenId);
},