use*_*439 7 javascript reactjs
使用react和webpack ..为什么下面的代码会导致错误:Uncaught (in promise) SyntaxError: Unexpected end of input(…)?谢谢
fetch(feedURL, {"mode": "no-cors"})
.then(response => response.json())
.then(function(data){
this.setState({
data: data
})
}.bind(this));
Run Code Online (Sandbox Code Playgroud)
小智 0
为了更好地理解您的错误,请在您的提取请求中添加一个 catch 案例。
另外,如果使用箭头函数,则不需要bind(this);
fetch(feedURL, {"mode": "no-cors"})
.then(response => response.json())
.then(data => {
this.setState({
data: data
});
})
.catch(resp => {
console.error(resp);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1456 次 |
| 最近记录: |