This commit is contained in:
2025-10-08 07:37:43 +07:00
parent 7645838eb8
commit 4df6ba7843
8 changed files with 158 additions and 19 deletions

View File

@@ -21,8 +21,16 @@ const userSlice = createSlice({
},
extraReducers: (bd) => {
bd.addCase(fetchUserData.pending, (state, action) => {
state.loading = true
})
bd.addCase(fetchUserData.fulfilled, (state, action) => {
state.data = action.payload
console.log("đã vào full", action.payload)
state.loading = false
state.data = action.payload
})
bd.addCase(fetchUserData.rejected, (state, action) => {
state.loading = false
})
}
})
@@ -31,8 +39,8 @@ const userSlice = createSlice({
const fetchUserData = createAsyncThunk(
"user/fetchUserData",
async () => {
let result = await Apis.user.findById(localStorage.getItem("userLogin"))
return result.data
let result = await Apis.user.me(localStorage.getItem("token")) as any
return result
}
)