【发布时间】:2022-11-29 02:09:21
【问题描述】:
大家好,我想在用 get/all 调用数组后从数组中获取特定值。 我的代码如下:
fetchUserDetails=()=>{
const username1 = localStorage.getItem('username')
var axios = require('axios');
var data = '';
var config = {
method: 'get',
url: 'localhost:3000/users/getDataByUsername/'+username1,
headers: { },
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
}
在这里,我获取了整个用户对象,在上面我只想显示整个项目中的 userEmail:
<Form.Control type="text" value={this.state.userEmail}/>
知道我该如何实现吗?使用上述值不起作用
<Form.Control type="text" value={this.state.userEmail}/> 。我写了这段代码,但没有成功
【问题讨论】: