Hello everyone, currently I am builing my first webshop as mern-stack with typescript. My authentication system works, but now I want to write the dashboard. I am used to overgive no data in the findAll or getStats function because I want to get all, that means I don’t need to overgive Id or data. So in javascript I have set a " _" as parameter and that has worked in my first mern-stack, but typescript knows not the type. How I can write this in typescript ? Thanks for your help.
That is my slice:
export const getAllUser = createAsyncThunk<object, _, AsyncThunkConfig>('/user/findAll', async (_, thunkAPI)=>{
try{
const token = thunkAPI.getState().auth.user!.accessToken;
return await userService.getAllUser(token);
}catch (error:any) {
const message =
(error.response &&
error.response.data &&
error.response.data.message) ||
error.message ||
error.toString()
return thunkAPI.rejectWithValue(message as string)
}
})
export const getUserStats = createAsyncThunk<object, _, AsyncThunkConfig>('/user/stats', async (_, thunkAPI)=>{
try{
const token = thunkAPI.getState().auth.user!.accessToken;
return await userService.getUserStats(token);
}catch (error:any) {
const message =
(error.response &&
error.response.data &&
error.response.data.message) ||
error.message ||
error.toString()
return thunkAPI.rejectWithValue(message as string)
}
})