0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

「fuelphpのrestコントローラでログインチェックを行う」でログアウトされていたときの処理をフロントで共通化したい

Posted at

fuelphpのrestコントローラでログインチェックを行う
でログインチェックに失敗したときの処理をajax毎に書きたくなかったので調べました。

$(document).ajaxError(function(e, jqXHR) {
    if (jqXHR.status === 401) {
        //ここに処理を書く
    }
});

axiosを使っている場合は以下

axios.interceptors.response.use(function (response) {
    return response;
}, function (error) {
    if (error.response.status === 401) {
       //ここに処理を書く
    }
    return Promise.reject(error);
});
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?