Location.reload (true) 只是旋转但不会重新加载页面

时间:2021-02-08 22:45:30

标签: javascript node.js authentication

我正在尝试从我的应用程序中注销用户,我有一个按钮侦听单击事件以执行注销算法,该算法类似于下面的代码,但是我只看到了旋转轮,什么也没有。

export const logout = async () => {
  try {
    const res = await axios({
      method: "GET",
      url: "http://localhost:3001/users/logout",
    });
    console.log(res)
     if ((res.data.status === "success")) {
      window.setTimeout(() => {
      location.reload(true);
      }, 1000)
     }
   
  } catch (err) {
    showAlert("error", "Error!! Logging out ! Please Try Again");
  }
};

Console.log 按预期返回所有内容 --- Console Result

0 个答案:

没有答案