Internal Server Error on failed in router

In my router, before I goes to the page I launch an rest api request to get data from server in by beforeEnter clause like below:

beforeEnter: (to, form, next) => {
              getData().then(
                (response) => {
                  //some logic to get data
                  next(); //if no error redirect to page
                },
                (error) => {
                  next(false); //on error not redirect on page - on this moment i want to show info about internal server error
                });
            }

and right now i have an question, how to show an toast/notification with "Internal server error" info when I have an error in my beforeEnter?

thanks for any help

1 thought on “Internal Server Error on failed in router”

  1. Hmmm, Ok, I do it

    on error:

    (error) => {
                  HelpersService.internalServerErrorToast();
                  next(false);
                }
    

    in service:

      internalServerErrorToast() {
        let bootStrapToaster = new BToast();
    
        bootStrapToaster.$bvToast.toast("500", {
          title: "Internal Server Error",
          toaster: "b-toaster-bottom-right",
          solid: true,
          variant: "danger",
          appendToast: false,
          noCloseButton: true,
          toastClass: "internalErrorToast",
        });
      }
    
    Reply

Leave a Comment