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