未为对象中的一键设置反应状态

时间:2020-07-31 00:22:38

标签: javascript reactjs

我真的不确定如何解释这一点。

我的网站(something)上有一个个人资料页面,可访问API(something

/profile返回以下JSON-/api/testAPI/currentuser.php

在我的react组件中,我使用以下功能在currentuser.php阶段获取此端点

{loggedin: true, uid: "3", username: "TechPhil", permissions: "none"}

不要问我为什么,但是我可以使用componentDidMount()来访问fetch("/api/testAPI/currentuser.php") .then((res) => res.json()) .then((res) => { this.setState({ apiResponse: res }) }) uidusername键,但是我出于某些原因根本无法访问permissions

我将完整的组件代码放在下面。

this.state.apiResponse.key

0 个答案:

没有答案
相关问题