title: Redux toolkit action is stuck in pending state even after api response is recieved
body: <p>I am using redux toolkit and all of the other actions for slice are working as expected but only editCountry action has problem. My editCountry action is stuck in country/editCountry/pending. I have no idea what is wrong with code.</p>
  <p>This is how redux slice code is defined.
  slice.js</p>
  <pre><code>const initialState = {
      countries: {},
      isLoading: false,
      isError: false,
      isSuccess: false,
      message: ''
  }
  
  export const editCountry = createAsyncThunk(
      'country/editCountry',
      async (payload, thunkAPI) =&gt; {
          try {
              const response = await apiProvider.editCountry(payload);
              return response;
          }
          catch (e) {
              return thunkAPI.rejectWithValue(e)
          }
      })
  
  const countriesSlice = createSlice({
      name: 'country',
      initialState,
      reducers: { },
      extraReducers: (builder) =&gt; {
        builder
               .addCase(editCountry.pending, (state, action) =&gt; {
                  state.isLoading = true
              })
              .addCase(editCountry.fulfilled, (state, action) =&gt; {
                  console.log('fulfilled before: ', state); // shown on console
                  console.log('fulfilled action: ', action.payload.data); // undefined
                  const unUpdatedCountries = state.countries.data.filter(c =&gt; c._id !== 
                    action.payload.data._id)
                  const updatedCountries  = [action.payload.data, ...unUpdatedCountries];
  
                  state.isLoading = false;
                  state.isSuccess = true;
                  state.countries = {...state.countries, data: updatedCountries };
                  console.log('fulfilled after: ', state);  // do not shown on console
  
              })
              .addCase(editCountry.rejected, (state, action) =&gt; {
                  state.isLoading = false;
                  state.isError = true;
                  state.message = action.payload;
              })
      }
  </code></pre>
  <p>Here is the Api helper method which is invoked inside editCountry action.
  ApiProvider.js</p>
  <pre><code>export const editCountry = async (payload) =&gt; {
      let token = getToken();
      const config = {
          headers: {
              Authorization: `Bearer ${token}`,
              &quot;Content-Type&quot;: &quot;application/json&quot;,
              Accept: &quot;application/json&quot;,
          },
      };
  
      try{
          const {data} = await axios.put(`${baseUrl}/edit-country`, payload, config);
          if(data.status){
              return Promise.resolve(data);
          }
          return Promise.reject(data.message);
      }
      catch (e) {
          return Promise.reject(e.message);
      }
  }
  </code></pre>
  <p>And here is my Submit method from where action is dispatched.
  Country.js</p>
  <pre><code>const handleSubmit = async (e, newFormData) =&gt; {
          e.preventDefault()
          const apiPayload = {
              Country_ID: newFormData.id,
              Name: newFormData.name,
              DialCode: newFormData.dialCode.includes(&quot;+&quot;) ? newFormData.dialCode : &quot;+&quot;+newFormData.dialCode,
              ISO: newFormData.iso,
              CallRate: newFormData.minutePrice,
              Blocked: newFormData.isBlocked.value,
          }
          try {
              await dispatch(editCountry(apiPayload)).unwrap()
              toggle()    // hide form modal
              toast.success('Country updated successfully');
          }
          catch (e) {
              setFormData({
                  ...formData,
                  errorMsg: e.message,
              });
              toggle();
              toast.error(e);
          }
      }
  </code></pre>
  <p>On action dispatch redux is stuck on pending but in network tab api call is completed.
  [enter image description here][1]</p>
  <p>Network tab image:
  [1]: [https://i.stack.imgur.com/X3rbA.png][1]</p>
  <p>Redux dev tools image:
  [1]: <a href="https://i.stack.imgur.com/sQUdJ.png" rel="nofollow noreferrer">https://i.stack.imgur.com/sQUdJ.png</a></p>