【发布时间】:2018-10-15 09:01:26
【问题描述】:
我正在用 react native CRNA 构建一个应用程序,在调用注册用户的个人资料图片后出现此错误。
对
require的调用期望恰好有 1 个字符串字面量参数,但这 被发现:require(this.state.pict)
我有点困惑如何从 API 调用用户信息项。这是我获取用户数据的代码。
fetch('someurl', {
method: 'GET',
headers:{
Authorization: 'token',
}
})
.then((response)=> response.json())
.then((responseJson)=> {
this.setState({
students: responseJson.data,
loading: false,
})
})
.catch((error)=>{
console.log(error);
});
我将该代码放在componentDidMount() 上并在图像源中调用this.state.pict,但得到了先前的错误。有人可以告诉我有什么问题吗?我被卡住了..非常感谢。
【问题讨论】:
标签: image api react-native profile