注销功能不起作用,'res'的功能从不读取

问题描述 投票:0回答:1

我正在尝试为React应用编写注销功能,但无法正常工作。

handleLogout () {
    API.logout()
      .then(res => this.props.history.push('/login'))
      .catch(err => console.error(err));
  }

res变成灰色,编辑器说它的功能从不读取。我究竟做错了什么?

我在按钮标签中调用该函数:

    <button id="logout" onClick={this.handleLogout} className="btn">LOG OUT</button>

[我正在尝试为React应用编写注销功能,但无法正常工作。.handleLogout(){API.logout().then(res => this.props.history.push('/ login')) .catch(err => console ....

javascript reactjs function jsx logout
1个回答
0
投票

正如Jayce444告诉编辑者有关res的警告与注销功能失败无关。打开开发工具,然后查看网络标签,为什么api失败

© www.soinside.com 2019 - 2024. All rights reserved.