File tree 1 file changed +2
-2
lines changed 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -437,7 +437,7 @@ const fetchUserById = createAsyncThunk(
437
437
- Requesting a user by ID, with loading state, and only one request at a time:
438
438
439
439
``` js
440
- import { createAsyncThunk , createSlice } from ' @reduxjs/toolkit'
440
+ import { createAsyncThunk , createSlice , unwrapResult } from ' @reduxjs/toolkit'
441
441
import { userAPI } from ' ./userAPI'
442
442
443
443
const fetchUserById = createAsyncThunk (
@@ -494,7 +494,7 @@ const UsersComponent = () => {
494
494
const fetchOneUser = async userId => {
495
495
try {
496
496
const resultAction = await dispatch (fetchUserById (userId))
497
- const user = resultAction . payload
497
+ const user = unwrapResult ( resultAction)
498
498
showToast (' success' , ` Fetched ${ user .name } ` )
499
499
} catch (err) {
500
500
showToast (' error' , ` Fetch failed: ${ err .message } ` )
You can’t perform that action at this time.
0 commit comments