educative.io

IMPORTANT changes for createAsyncThunk function and also another improvement for the code

Take into account when our promise is rejected in a createAsyncThunk function, it passes the error as an object inside of returned action.

So instead of action.payload, you should use action.error.message, or destructure error and error.message in order to update the error state.

Improvement for the code

It has a bug, basically when you received the error message once, the loading state do not show, so you have to set the error state to null in the pending extra reducer.

Hi Ulises,

This is Asmat from Educative; thank you for pointing it out. Both issues have been resolved now.

1 Like