async/await
React Native ile kullanıyorum.Neden getiri garip bir tamsayı karması döndürüyor - bölüm 2?
response.json()
My sonucudur: {_45: 0, _81: 0, _65: null, _54: null} Sebebi ne olursa olsun
, ben _65 bulunan istiyor ve fiili tepki Fikrim yok Bu rastgele anahtarlar nelerdir.
.json()
'un bir Promise döndürmesiyle ilgili olduğu anlaşılıyor.
componentDidMount() {
this.getData().then(data => this.setState({ data }))
}
async getData() {
try {
let response = await fetch(myUrl)
let json = await response.json()
return json
} catch(err) {
Alert.alert(null, err)
}
}
render() {
const { data } = this.state
...
Bu http://stackoverflow.com/questions/34539743/ ile ilgilidir neden-get-fetch-dönüş-a-garip-karma-tamsayılar – Dan
Cevap: '' 'this.getData(). sonra (data => this.setState ({data}))' '' – Dan