title: How do I Store JSON data in React Native with setState
body: <p>I am trying to change and store the latitude and longitude results from <a href="http://api.postcodes.io/postcodes/NW10AP" rel="nofollow noreferrer">http://api.postcodes.io/postcodes/NW10AP</a> into my Marker.coordinate state so my map can render the new marker.</p>
  
  <p>Really struggling to figure out a way this can be done and would greatly appreciate any help! :)</p>
  
  <p>Please have a look at the code below</p>
  
  <pre><code>    import React from 'react';
      import { MapView } from 'expo';
      import { Marker } from 'react-native-maps';
      import {Image, ActivityIndicator, View, Text, FlatList} from 'react-native';
  
  
  
      export default class App extends React.Component {
  
        state = {
          region: {
            latitude: 51.5074,
            longitude: 0.1278,
            latitudeDelta: 0.1,
            longitudeDelta: 0.1
          },
          marker: {
              title: 'Hello there',
              coordinate: {latitude: 51.5074, longitude: 0.1278}
              }
          }
  
  
  
        onRegionChange = (region) =&gt; {
          this.setState({region});
          // console.log(region)
        }
  
             componentDidMount(){
          return fetch('http://api.postcodes.io/postcodes/sw151pf')
            .then((response) =&gt; response.json())
            .then((responseJson) =&gt; {
              let marker = {...this.state.marker}
              marker.coordinate.latitude = responseJson.result.latitude;
              marker.coordinate.longitude = responseJson.result.longitude;
  
  
              this.setState({
                marker
              }, function(){
  
              });
  
            })
            .catch((error) =&gt;{
              console.error(error);
            });
        }
  
  
  
  
        render() {
  
          return (
  
            &lt;MapView
              style={{ flex: 1 }}
              region={this.state.region}
              onRegionChange={this.onRegionChange}
  
            &gt;
  
              &lt;Marker
                coordinate={this.state.marker.coordinate}
                title={this.state.marker.title}
              /&gt;
  
            &lt;/MapView&gt;
  
          )
        }
      }
  </code></pre>