【发布时间】:2021-03-10 13:18:20
【问题描述】:
我想从数据库中检索所有项目,然后在 table
上显示用户我可以只显示当前用户,这是我的代码:
const API_URL = "http://localhost:8080/api/auth/";
class AuthService {
getCurrentUser() {
return JSON.parse(localStorage.getItem('user'));;
}
const currentUser = AuthService.getCurrentUser();
<TableBody>
{this.state.users.map(row => (
<TableRow key={row.id}>
<TableCell component="th" scope="row">
{currentUser.id}
</TableCell>
<TableCell align="right">{currentUser.username}</TableCell>
<TableCell align="right">{currentUser.email}</TableCell>
<TableCell align="right">{currentUser.roles}</TableCell>
</TableRow>
【问题讨论】:
标签: javascript reactjs mongoose axios jsx