title: Can't get data from object array | React.js - openweatherAPI
body: <p>I fetch data from openweatherAPI by using react-redux Toolkit. I can get name but when I want to get main.temp it gives an error</p>
  <blockquote>
  <p>typeError: Cannot read properties of undefined (reading 'temp')</p>
  </blockquote>
  <pre><code>export const fetchDefault = createAsyncThunk('weather/getWeather', async (selectedCity) =&gt; {
  const res = await axios(`https://api.openweathermap.org/data/2.5/weather?q=${selectedCity}&amp;appid=6d735f036884219e3a12eeb6f7bf6f93`)
  return res.data});
  </code></pre>
  <p>ExtraReducers</p>
  <pre><code>[fetchDefault.fulfilled]: (state , action) =&gt; {
          state.item = action.payload;
          console.log(state.item)
      },
  </code></pre>
  <p>It works if I <code>return res.data.main</code> but this time cant get name .</p>
  <p>index.js</p>
  <pre><code>const getCity  = useSelector((state) =&gt; state.weather.item);
  {getCity.main.temp} // Gives Error..
  </code></pre>
  <p>Array looks like this..</p>
  <pre><code>    {
   &quot;weather&quot;: [
     {
       &quot;id&quot;: 802,
       &quot;main&quot;: &quot;Clouds&quot;,
       &quot;description&quot;: &quot;scattered clouds&quot;,
     }
   ],
   &quot;main&quot;: {
     &quot;temp&quot;: 300.15,
     &quot;pressure&quot;: 1007,
     &quot;humidity&quot;: 74,
     &quot;temp_min&quot;: 300.15,
     &quot;temp_max&quot;: 300.15
   },
   &quot;wind&quot;: {
     &quot;speed&quot;: 3.6,
     &quot;deg&quot;: 160
   &quot;id&quot;: 2172797,
   &quot;name&quot;: &quot;Cairns&quot;,
   &quot;cod&quot;: 200
   }
  </code></pre>