2
任何想法,为什么我不能得到fetch()
在工作反应本土?完整的代码在这里RN播放: https://rnplay.org/apps/L80w2w不能得到`取()`工作中反应原住民
下面是我试图让工作在阵营本地工作ReactJS小提琴:https://jsfiddle.net/ssorallen/fEsYt/
componentDidMount: function() {
var _this = this;
var queryParams = "fn" + Date.now() + '/';
var queryUrl = "https://www.reddit.com/reddits.json?jsonp=" + queryParams;
fetch(queryUrl)
.then(response => response.json())
.then(responseData => this._handleResponse(responseData.data.children))
.catch(error => this.setState({
isLoading: false,
errorMessage: 'Something bad happened - loading navigationItems: \n' + error
}));
},
_handleResponse(results) {
this.setState({ isLoading: false });
if (results.length > 0) {
this.setState({
navigationItems: results
});
} else {
this.setState({ errorMessage: "Can't find JSON." });
}
},
无法使用rnplay链接,请在snack.expo.com中创建一个新链接 – locropulenton