首页 > 解决方案 > 如果登录会话在 laravel 应用程序中过期,jQuery 如何捕获?

问题描述

在我的 Laravel 8 应用程序中,我使用 jQuery 3.5.1 并想知道是否有办法以防登录会话过期以在 1 个位置捕获此错误以从应用程序注销?

就像我在 vuejs 中一样:

this.$http.interceptors.response.use(undefined, function (error) {

    return new Promise(function (/*resolve, reject*/) {
        if (typeof error.response.status !== 'undefined' && error.response.status === 401) {
            self.$store.dispatch('logout')  // DEBUGGING
            self.showPopupMessage('Access', 'Not authorized !', 'warn')
            ...
        }

标签: jquerylaravel

解决方案


推荐阅读