mealie/frontend/plugins/toast.client.ts
Hayden ccfaa02b03
Fix/multiple bug reports (#1002)
* fix type issues for #999

* fix regression #995

* remove error from frontend and log error #996

* cleanup darkmode on login page

* keep primary color bg
2022-02-23 15:04:45 -09:00

18 lines
518 B
TypeScript

import { Plugin } from "@nuxt/types";
import { NuxtAxiosInstance } from "@nuxtjs/axios";
import { alert } from "~/composables/use-toast";
const toastPlugin: Plugin = ({ $axios }: { $axios: NuxtAxiosInstance }) => {
$axios.onResponse((response) => {
if (response?.data?.message) {
alert.info(response.data.message);
}
});
$axios.onError((error) => {
if (error.response?.data?.detail?.message) {
alert.error(error.response.data.detail.message);
}
});
};
export default toastPlugin;