Why does fetch return a strange hash of integers - part 2?

I am using async/await with React Native.

My result from response.json() : {_45: 0, _81: 0, _65: null, _54: null}

For some reason, the actual answer I want is in _65, and I don't know what these random keys are.

This seems to be due to the .json() returning Promise.

  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 ... 
+1
source share
1 answer

Answer: this.getData (). then (data => this.setState ({data}))

+3
source

Source: https://habr.com/ru/post/1239537/


All Articles