import { useToast } from "vue-toastification";
import { useI18n } from "vue-i18n";
export default function useToastMsg(message, type) {
const { t } = useI18n();
const toast = useToast()
if (type == "success") {
return toast.success(t(`${message}`))
} else if (type == "error") {
return toast.error(t(`${message}`))
}
}
I am trying to use this function in the store after action has taken place.
store.js
import useToast from "@/composables/toast"
in action function:
useToast("submit", "success")
error message:
Uncaught (in promise) SyntaxError: Must be called at the top of a setup function
How can I work around this?