thunkAPIrejectWithValuereserror
ThunkAPI.rejectWithValue is a utility provided by Redux Toolkit's createAsyncThunk. It is part of the thunkAPI object passed to the payload creator function and is used to dispatch a rejected action with a custom payload. The thunkAPI object also includes other helpers such as dispatch, getState, extra, requestId, and signal.
The primary purpose of rejectWithValue is to propagate structured error information from an async operation. When
Common usage involves catching an error from an async operation and, when useful data is available, calling
In reducers, handling a rejected action typically checks action.payload first. If a payload exists, it represents
Overall, rejectWithValue provides a controlled way to surface structured, known errors from asynchronous thunks, improving error